-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (62 loc) · 2.46 KB
/
ulid_build_release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: ULID Tool Build and Release
on:
pull_request_target:
branches:
- main
types:
- closed
jobs:
release:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
env:
IS_PROD: ${{ contains(github.event.pull_request.head.ref, 'prod') }}
VERSION_NUMBER: ${{ github.run_number }}
FILE_SUFFIX: ${{ contains(github.event.pull_request.head.ref, 'prod') && '' || '-beta' }}
steps:
- uses: actions/checkout@v2
with:
ref: 'refs/heads/main' # Ensures the main branch is checked out after merge
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Build and Test ULID Tool
run: |
cd tools/ulid
cargo build --release --verbose
cargo test --verbose
- name: Debug Info
run: |
echo "FILE_SUFFIX: ${{ env.FILE_SUFFIX }}"
echo "IS_PROD: ${{ env.IS_PROD }}"
echo "Branch: ${{ github.event.pull_request.head.ref }}"
- name: Rename Binary
if: env.FILE_SUFFIX != ''
run: |
mv tools/ulid/target/release/ulid tools/ulid/target/release/ulid${{ env.FILE_SUFFIX }}
- name: Archive Binary
run: |
cd tools/ulid/target/release
zip ulid-v${{ env.VERSION_NUMBER }}${{ env.FILE_SUFFIX }}.zip ulid${{ env.FILE_SUFFIX }}
- name: Create Release
id: create_release # Ensure this ID is correctly set to reference in later steps
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ulid-v${{ env.VERSION_NUMBER }}${{ env.FILE_SUFFIX }}
release_name: ULID Release v${{ env.VERSION_NUMBER }}${{ env.FILE_SUFFIX }}
draft: false
prerelease: ${{ !env.IS_PROD }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # Correctly reference the output of the create_release step
asset_path: ./tools/ulid/target/release/ulid-v${{ env.VERSION_NUMBER }}${{ env.FILE_SUFFIX }}.zip
asset_name: ulid-v${{ env.VERSION_NUMBER }}${{ env.FILE_SUFFIX }}.zip
asset_content_type: application/zip