|
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | build: |
10 | | - name: Build on ${{ matrix.os }} |
| 10 | + name: ${{ matrix.target }} |
11 | 11 | runs-on: ${{ matrix.os }} |
12 | 12 | strategy: |
| 13 | + fail-fast: false |
13 | 14 | matrix: |
14 | | - os: [ ubuntu-latest, macos-latest, windows-latest ] |
15 | | - crate: [ aspect2-stm32-updater, soundchip-cli ] |
| 15 | + target: |
| 16 | + - x86_64-pc-windows-msvc |
| 17 | + - aarch64-pc-windows-msvc |
| 18 | + - x86_64-unknown-linux-gnu |
| 19 | + - aarch64-unknown-linux-gnu |
| 20 | + - x86_64-apple-darwin |
| 21 | + - aarch64-apple-darwin |
| 22 | + include: |
| 23 | + - target: x86_64-pc-windows-msvc |
| 24 | + os: windows-latest |
| 25 | + - target: aarch64-pc-windows-msvc |
| 26 | + os: windows-latest |
| 27 | + - target: x86_64-unknown-linux-gnu |
| 28 | + os: ubuntu-latest |
| 29 | + - target: aarch64-unknown-linux-gnu |
| 30 | + os: ubuntu-latest |
| 31 | + - target: x86_64-apple-darwin |
| 32 | + os: macos-latest |
| 33 | + - target: aarch64-apple-darwin |
| 34 | + os: macos-latest |
16 | 35 |
|
17 | 36 | steps: |
18 | 37 | - name: Checkout |
19 | | - uses: actions/checkout@v6 |
| 38 | + uses: actions/checkout@v7 |
| 39 | + |
| 40 | + - name: Install Rust |
| 41 | + uses: dtolnay/rust-toolchain@stable |
| 42 | + with: |
| 43 | + targets: ${{ matrix.target }} |
20 | 44 |
|
21 | 45 | - name: Cache cargo registry and target |
22 | | - uses: actions/cache@v4 |
| 46 | + uses: actions/cache@v6 |
23 | 47 | with: |
24 | 48 | path: | |
25 | 49 | ~/.cargo/registry |
26 | 50 | ~/.cargo/git |
27 | | - ${{ matrix.crate }}/target |
28 | | - key: ${{ runner.os }}-cargo-${{ matrix.crate }}-${{ hashFiles('**/Cargo.lock') }} |
29 | | - |
30 | | - - name: Setup Rust |
31 | | - uses: actions-rs/toolchain@v1 |
32 | | - with: |
33 | | - toolchain: stable |
34 | | - |
35 | | - - name: Build crate |
36 | | - run: cargo build --manifest-path ${{ matrix.crate }}/Cargo.toml --release --verbose |
| 51 | + target |
| 52 | + key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
37 | 53 |
|
38 | | - - name: Package artifacts (non-Windows) |
39 | | - if: runner.os != 'Windows' |
| 54 | + - name: Install aarch64 linker |
| 55 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
40 | 56 | run: | |
41 | | - mkdir -p release_artifacts |
42 | | - cp ${{ matrix.crate }}/target/release/${{ matrix.crate }} release_artifacts/${{ matrix.crate }}-${{ matrix.os }} || true |
43 | | - zip -r release-${{ matrix.crate }}-${{ matrix.os }}.zip release_artifacts |
44 | | - sha256sum release-${{ matrix.crate }}-${{ matrix.os }}.zip | awk '{print $1}' > release-${{ matrix.crate }}-${{ matrix.os }}.sha256 |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 59 | + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" |
45 | 60 |
|
46 | | - - name: Package artifacts (Windows) |
47 | | - if: runner.os == 'Windows' |
48 | | - shell: pwsh |
| 61 | + - name: Build workspace |
| 62 | + run: cargo build --workspace --release --all-features --target ${{ matrix.target }} --verbose |
| 63 | + |
| 64 | + - name: Stage binaries |
| 65 | + shell: bash |
49 | 66 | run: | |
50 | | - New-Item -ItemType Directory -Path release_artifacts -Force | Out-Null |
51 | | - $exe = "${{ matrix.crate }}.exe" |
52 | | - $src = Join-Path -Path (Join-Path -Path "${{ matrix.crate }}" -ChildPath "target\release") -ChildPath $exe |
53 | | - $dst = "release_artifacts\${{ matrix.crate }}-${{ matrix.os }}.exe" |
54 | | - Copy-Item -Path $src -Destination $dst -ErrorAction SilentlyContinue |
55 | | - $zipname = "release-${{ matrix.crate }}-${{ matrix.os }}.zip" |
56 | | - Compress-Archive -Path release_artifacts/* -DestinationPath $zipname -Force |
57 | | - (Get-FileHash $zipname -Algorithm SHA256).Hash | Out-File -Encoding ascii ("${zipname}.sha256") |
| 67 | + ext="" |
| 68 | + [[ "${{ matrix.target }}" == *windows* ]] && ext=".exe" |
| 69 | + mkdir dist |
| 70 | + for bin in aspect2-stm32-updater postcode_emu soundchip_cli flash_cli i2c_scan; do |
| 71 | + cp "target/${{ matrix.target }}/release/${bin}${ext}" "dist/${bin}-${{ matrix.target }}${ext}" |
| 72 | + done |
58 | 73 |
|
59 | | - - name: Upload per-OS release artifact |
60 | | - uses: actions/upload-artifact@v4 |
| 74 | + - name: Upload artifacts |
| 75 | + uses: actions/upload-artifact@v7 |
61 | 76 | with: |
62 | | - name: release-${{ matrix.crate }}-${{ matrix.os }} |
63 | | - path: | |
64 | | - release-${{ matrix.crate }}-${{ matrix.os }}.zip |
65 | | - release-${{ matrix.crate }}-${{ matrix.os }}.sha256 |
| 77 | + name: ${{ matrix.target }} |
| 78 | + path: dist/* |
66 | 79 |
|
67 | 80 | create_release: |
68 | 81 | if: startsWith(github.ref, 'refs/tags/') |
69 | 82 | name: Create GitHub Release |
70 | 83 | runs-on: ubuntu-latest |
71 | 84 | needs: build |
72 | 85 | steps: |
73 | | - - name: Checkout |
74 | | - uses: actions/checkout@v4 |
75 | | - |
76 | 86 | - name: Download build artifacts |
77 | | - uses: actions/download-artifact@v4 |
| 87 | + uses: actions/download-artifact@v8 |
78 | 88 | with: |
79 | 89 | path: release_artifacts_all |
80 | | - |
81 | | - - name: List downloaded artifacts |
82 | | - run: ls -la release_artifacts_all |
| 90 | + merge-multiple: true |
83 | 91 |
|
84 | 92 | - name: Create GitHub Release and upload artifacts |
85 | | - uses: softprops/action-gh-release@v1 |
| 93 | + uses: softprops/action-gh-release@v3 |
86 | 94 | with: |
87 | 95 | files: release_artifacts_all/* |
88 | 96 | env: |
|
0 commit comments