|
| 1 | +# Builds cross-platform binaries and uploads to GitHub Releases. |
| 2 | +# Binaries are discoverable by cargo-binstall (https://github.com/cargo-bins/cargo-binstall). |
| 3 | +# Triggered automatically when release-plz publishes a dial9-viewer release. |
| 4 | +name: Build Binaries |
| 5 | + |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build ${{ matrix.target }} |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + if: startsWith(github.event.release.tag_name, 'dial9-viewer-v') |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - target: x86_64-unknown-linux-gnu |
| 23 | + os: ubuntu-latest |
| 24 | + archive: tar.gz |
| 25 | + - target: aarch64-unknown-linux-gnu |
| 26 | + os: ubuntu-24.04-arm |
| 27 | + archive: tar.gz |
| 28 | + - target: x86_64-apple-darwin |
| 29 | + os: macos-latest |
| 30 | + archive: tar.gz |
| 31 | + - target: aarch64-apple-darwin |
| 32 | + os: macos-latest |
| 33 | + archive: tar.gz |
| 34 | + - target: x86_64-pc-windows-msvc |
| 35 | + os: windows-latest |
| 36 | + archive: zip |
| 37 | + |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + persist-credentials: false |
| 42 | + |
| 43 | + - uses: dtolnay/rust-toolchain@stable |
| 44 | + with: |
| 45 | + targets: ${{ matrix.target }} |
| 46 | + |
| 47 | + - run: cargo build --release --target ${{ matrix.target }} -p dial9-viewer |
| 48 | + env: |
| 49 | + RUSTFLAGS: "--cfg tokio_unstable" |
| 50 | + |
| 51 | + - name: Determine version |
| 52 | + id: version |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + TAG="${{ github.event.release.tag_name }}" |
| 56 | + # Strip package name prefix (e.g. "dial9-viewer-v0.3.1" -> "v0.3.1") |
| 57 | + VERSION="${TAG##*-v}" |
| 58 | + echo "version=v${VERSION}" >> "$GITHUB_OUTPUT" |
| 59 | +
|
| 60 | + - name: Package (Unix) |
| 61 | + if: ${{ matrix.archive == 'tar.gz' }} |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + cd target/${{ matrix.target }}/release |
| 65 | + tar -czvf ../../../dial9-viewer-${{ matrix.target }}-${{ steps.version.outputs.version }}.tar.gz dial9-viewer |
| 66 | +
|
| 67 | + - name: Package (Windows) |
| 68 | + if: ${{ matrix.archive == 'zip' }} |
| 69 | + shell: pwsh |
| 70 | + run: | |
| 71 | + cd target/${{ matrix.target }}/release |
| 72 | + Compress-Archive -Path dial9-viewer.exe -DestinationPath ../../../dial9-viewer-${{ matrix.target }}-${{ steps.version.outputs.version }}.zip |
| 73 | +
|
| 74 | + - name: Upload release asset |
| 75 | + uses: softprops/action-gh-release@v2 |
| 76 | + with: |
| 77 | + files: dial9-viewer-${{ matrix.target }}-${{ steps.version.outputs.version }}.${{ matrix.archive }} |
0 commit comments