|
8 | 8 | jobs:
|
9 | 9 | release:
|
10 | 10 | name: Build & Release ${{ matrix.target }}
|
11 |
| - runs-on: ubuntu-latest |
| 11 | + runs-on: ${{ matrix.os }} |
12 | 12 | permissions:
|
13 |
| - contents: write |
| 13 | + contents: write |
14 | 14 | strategy:
|
15 | 15 | fail-fast: false
|
16 | 16 | 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 |
18 | 30 |
|
19 | 31 | steps:
|
20 | 32 | - name: Checkout repository
|
21 | 33 | 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 |
22 | 41 |
|
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 }} |
25 | 46 |
|
26 |
| - - name: Compile binary |
| 47 | + - name: Build binary |
27 | 48 | 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 ../../.. |
28 | 68 |
|
29 |
| - - name: Upload GitHub Release |
| 69 | + - name: Upload Release Asset |
30 | 70 | uses: softprops/action-gh-release@v2
|
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | 73 | 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