| 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - "v*" |
| 7 | |
| 8 | permissions: |
| 9 | contents: write |
| 10 | |
| 11 | jobs: |
| 12 | changelog: |
| 13 | name: Generate changelog |
| 14 | runs-on: ubuntu-latest |
| 15 | outputs: |
| 16 | release_notes: ${{ steps.git-cliff.outputs.content }} |
| 17 | steps: |
| 18 | - uses: actions/checkout@v4 |
| 19 | with: |
| 20 | fetch-depth: 0 |
| 21 | |
| 22 | - name: Generate release notes |
| 23 | id: git-cliff |
| 24 | uses: orhun/git-cliff-action@v4 |
| 25 | with: |
| 26 | config: cliff.toml |
| 27 | args: --verbose --latest --strip header |
| 28 | env: |
| 29 | GITHUB_REPO: ${{ github.repository }} |
| 30 | |
| 31 | - name: Generate full changelog |
| 32 | uses: orhun/git-cliff-action@v4 |
| 33 | with: |
| 34 | config: cliff.toml |
| 35 | args: --verbose |
| 36 | env: |
| 37 | OUTPUT: CHANGELOG.md |
| 38 | GITHUB_REPO: ${{ github.repository }} |
| 39 | |
| 40 | - name: Commit changelog |
| 41 | run: | |
| 42 | git config user.name "github-actions[bot]" |
| 43 | git config user.email "github-actions[bot]@users.noreply.github.com" |
| 44 | git add CHANGELOG.md |
| 45 | git diff --staged --quiet || git commit -m "chore(release): update CHANGELOG.md for ${{ github.ref_name }}" |
| 46 | git push origin HEAD:main |
| 47 | |
| 48 | build: |
| 49 | name: Build ${{ matrix.target }} |
| 50 | needs: changelog |
| 51 | runs-on: ${{ matrix.os }} |
| 52 | strategy: |
| 53 | matrix: |
| 54 | include: |
| 55 | - target: x86_64-unknown-linux-gnu |
| 56 | os: ubuntu-latest |
| 57 | archive: tar.gz |
| 58 | - target: aarch64-unknown-linux-gnu |
| 59 | os: ubuntu-latest |
| 60 | archive: tar.gz |
| 61 | - target: x86_64-apple-darwin |
| 62 | os: macos-latest |
| 63 | archive: tar.gz |
| 64 | - target: aarch64-apple-darwin |
| 65 | os: macos-latest |
| 66 | archive: tar.gz |
| 67 | - target: x86_64-pc-windows-msvc |
| 68 | os: windows-latest |
| 69 | archive: zip |
| 70 | |
| 71 | steps: |
| 72 | - uses: actions/checkout@v4 |
| 73 | |
| 74 | - name: Install Rust |
| 75 | uses: dtolnay/rust-toolchain@stable |
| 76 | with: |
| 77 | targets: ${{ matrix.target }} |
| 78 | |
| 79 | - name: Install cross-compilation tools (Linux aarch64) |
| 80 | if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 81 | run: | |
| 82 | sudo apt-get update |
| 83 | sudo apt-get install -y gcc-aarch64-linux-gnu |
| 84 | |
| 85 | - name: Configure cross-compilation (Linux aarch64) |
| 86 | if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 87 | run: | |
| 88 | echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml |
| 89 | echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml |
| 90 | |
| 91 | - name: Build |
| 92 | run: cargo build --release --target ${{ matrix.target }} |
| 93 | |
| 94 | - name: Package (Unix) |
| 95 | if: matrix.archive == 'tar.gz' |
| 96 | shell: bash |
| 97 | run: | |
| 98 | BINARY=target/${{ matrix.target }}/release/sipp |
| 99 | ARCHIVE=sipp-${{ github.ref_name }}-${{ matrix.target }}.tar.gz |
| 100 | tar -czf "$ARCHIVE" -C "$(dirname $BINARY)" "$(basename $BINARY)" |
| 101 | echo "ASSET=$ARCHIVE" >> $GITHUB_ENV |
| 102 | |
| 103 | - name: Package (Windows) |
| 104 | if: matrix.archive == 'zip' |
| 105 | shell: pwsh |
| 106 | run: | |
| 107 | $binary = "target\${{ matrix.target }}\release\sipp.exe" |
| 108 | $archive = "sipp-${{ github.ref_name }}-${{ matrix.target }}.zip" |
| 109 | Compress-Archive -Path $binary -DestinationPath $archive |
| 110 | echo "ASSET=$archive" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 111 | |
| 112 | - name: Upload to release |
| 113 | uses: softprops/action-gh-release@v2 |
| 114 | with: |
| 115 | body: ${{ needs.changelog.outputs.release_notes }} |
| 116 | files: ${{ env.ASSET }} |