Skip to content

Commit 5c3f6d6

Browse files
committed
update release-binary worfklow to support multiple targets
1 parent beaf536 commit 5c3f6d6

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

.github/workflows/release-binary.yml

+53-9
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,70 @@ on:
88
jobs:
99
release:
1010
name: Build & Release ${{ matrix.target }}
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
1212
permissions:
13-
contents: write
13+
contents: write
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
target: [x86_64-unknown-linux-gnu]
17+
include:
18+
- target: x86_64-unknown-linux-gnu
19+
os: ubuntu-latest
20+
extension: ""
21+
name: linux-x86_64
22+
- target: x86_64-pc-windows-msvc
23+
os: windows-latest
24+
extension: ".exe"
25+
name: windows-x86_64
26+
- target: aarch64-apple-darwin
27+
os: macos-latest
28+
extension: ""
29+
name: macos-aarch64
1830

1931
steps:
2032
- name: Checkout repository
2133
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Get tag name
38+
shell: bash
39+
run: |
40+
echo "RELEASE_TAG=${GITHUB_REF_NAME:-v0.1.0-test}" >> $GITHUB_ENV
2241
23-
- name: Add targets
24-
run: rustup target add "${{ matrix.target }}"
42+
- name: Install Rust toolchain
43+
uses: dtolnay/rust-toolchain@stable
44+
with:
45+
targets: ${{ matrix.target }}
2546

26-
- name: Compile binary
47+
- name: Build binary
2748
run: cargo build --release --target ${{ matrix.target }}
49+
env:
50+
CARGO_TARGET_DIR: target
51+
52+
- name: Prepare release assets
53+
shell: bash
54+
run: |
55+
cd target/${{ matrix.target }}/release
56+
BINARY_NAME="amd${{ matrix.extension }}"
57+
if [ -f "$BINARY_NAME" ]; then
58+
ARCHIVE_NAME="amd-${{ env.RELEASE_TAG }}-${{ matrix.name }}.tar.gz"
59+
tar -czf "../../../$ARCHIVE_NAME" "$BINARY_NAME"
60+
echo "Created archive: $ARCHIVE_NAME"
61+
echo "ASSET_PATH=$ARCHIVE_NAME" >> $GITHUB_ENV
62+
else
63+
echo "Error: Binary $BINARY_NAME not found"
64+
ls -la
65+
exit 1
66+
fi
67+
cd ../../..
2868
29-
- name: Upload GitHub Release
69+
- name: Upload Release Asset
3070
uses: softprops/action-gh-release@v2
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3173
with:
32-
files: target/${{ matrix.target }}/release/*
33-
token: ${{ secrets.GITHUB_TOKEN }}
74+
files: ${{ env.ASSET_PATH }}
75+
tag_name: ${{ env.RELEASE_TAG }}
76+
name: Release ${{ env.RELEASE_TAG }}
77+
generate_release_notes: true

0 commit comments

Comments
 (0)