|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build ${{ matrix.target }} |
| 14 | + runs-on: ${{ matrix.runner }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - target: x86_64-apple-darwin |
| 20 | + runner: macos-latest |
| 21 | + asset_name: dstimer-macos-x86_64 |
| 22 | + |
| 23 | + - target: aarch64-apple-darwin |
| 24 | + runner: macos-latest |
| 25 | + asset_name: dstimer-macos-aarch64 |
| 26 | + |
| 27 | + - target: x86_64-unknown-linux-gnu |
| 28 | + runner: ubuntu-latest |
| 29 | + asset_name: dstimer-linux-x86_64 |
| 30 | + |
| 31 | + - target: aarch64-unknown-linux-gnu |
| 32 | + runner: ubuntu-latest |
| 33 | + asset_name: dstimer-linux-aarch64 |
| 34 | + use_cross: true |
| 35 | + |
| 36 | + - target: x86_64-pc-windows-msvc |
| 37 | + runner: windows-latest |
| 38 | + asset_name: dstimer-windows-x86_64.exe |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Install Rust toolchain |
| 44 | + uses: dtolnay/rust-toolchain@stable |
| 45 | + with: |
| 46 | + targets: ${{ matrix.target }} |
| 47 | + |
| 48 | + - name: Install ALSA dev libraries (Linux x86_64) |
| 49 | + if: matrix.target == 'x86_64-unknown-linux-gnu' |
| 50 | + run: sudo apt-get update && sudo apt-get install -y libasound2-dev pkg-config |
| 51 | + |
| 52 | + - name: Install cross (Linux aarch64) |
| 53 | + if: matrix.use_cross == true |
| 54 | + uses: taiki-e/install-action@cross |
| 55 | + |
| 56 | + - name: Build (cross) |
| 57 | + if: matrix.use_cross == true |
| 58 | + run: cross build --release --target ${{ matrix.target }} |
| 59 | + |
| 60 | + - name: Build (cargo) |
| 61 | + if: matrix.use_cross != true |
| 62 | + run: cargo build --release --target ${{ matrix.target }} |
| 63 | + |
| 64 | + - name: Rename binary (Unix) |
| 65 | + if: matrix.runner != 'windows-latest' |
| 66 | + run: cp target/${{ matrix.target }}/release/dstimer ${{ matrix.asset_name }} |
| 67 | + |
| 68 | + - name: Rename binary (Windows) |
| 69 | + if: matrix.runner == 'windows-latest' |
| 70 | + run: cp target/${{ matrix.target }}/release/dstimer.exe ${{ matrix.asset_name }} |
| 71 | + |
| 72 | + - name: Upload artifact |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: ${{ matrix.asset_name }} |
| 76 | + path: ${{ matrix.asset_name }} |
| 77 | + |
| 78 | + release: |
| 79 | + name: Create GitHub Release |
| 80 | + needs: build |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/download-artifact@v4 |
| 84 | + with: |
| 85 | + path: artifacts |
| 86 | + merge-multiple: true |
| 87 | + |
| 88 | + - name: Create release and upload assets |
| 89 | + uses: softprops/action-gh-release@v2 |
| 90 | + with: |
| 91 | + files: artifacts/* |
| 92 | + generate_release_notes: true |
0 commit comments