Release Binaries #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Binaries | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v0.6.1)" | |
| required: true | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| - target: x86_64-apple-darwin | |
| os: macos-13 | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| cross: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create enterprise stub | |
| run: | | |
| if [ ! -f enterprise/Cargo.toml ]; then | |
| mkdir -p enterprise/src | |
| cat > enterprise/Cargo.toml << 'STUB' | |
| [package] | |
| name = "tracevault-enterprise" | |
| version = "0.1.0" | |
| edition = "2021" | |
| publish = false | |
| [dependencies] | |
| tracevault-core = { path = "../crates/tracevault-core" } | |
| async-trait = "0.1" | |
| STUB | |
| echo "" > enterprise/src/lib.rs | |
| fi | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: ${{ matrix.target }} | |
| - name: Install cross | |
| if: matrix.cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build (native) | |
| if: ${{ !matrix.cross }} | |
| run: cargo build --release --target ${{ matrix.target }} --package tracevault-cli | |
| - name: Build (cross) | |
| if: matrix.cross | |
| run: cross build --release --target ${{ matrix.target }} --package tracevault-cli | |
| - name: Package | |
| shell: bash | |
| run: | | |
| tag="${{ github.event.release.tag_name || inputs.tag }}" | |
| archive="tracevault-${tag}-${{ matrix.target }}" | |
| mkdir -p "$archive" | |
| cp "target/${{ matrix.target }}/release/tracevault" "$archive/" | |
| cp LICENSE README.md "$archive/" 2>/dev/null || true | |
| tar czf "${archive}.tar.gz" "$archive" | |
| if command -v shasum &>/dev/null; then | |
| shasum -a 256 "${archive}.tar.gz" > "${archive}.tar.gz.sha256" | |
| else | |
| sha256sum "${archive}.tar.gz" > "${archive}.tar.gz.sha256" | |
| fi | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.release.tag_name || inputs.tag }} | |
| files: | | |
| tracevault-*.tar.gz | |
| tracevault-*.tar.gz.sha256 | |
| update-homebrew: | |
| name: Update Homebrew formula | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Wait for assets to be available | |
| run: sleep 10 | |
| - name: Get release info | |
| id: release | |
| run: | | |
| tag="${{ github.event.release.tag_name || inputs.tag }}" | |
| version="${tag#v}" | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Download checksums | |
| run: | | |
| tag="${{ steps.release.outputs.tag }}" | |
| base="https://github.com/softwaremill/tracevault/releases/download/${tag}" | |
| for target in aarch64-apple-darwin x86_64-apple-darwin x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do | |
| curl -sL "${base}/tracevault-${tag}-${target}.tar.gz.sha256" -o "${target}.sha256" | |
| done | |
| - name: Parse checksums | |
| id: sha | |
| run: | | |
| for target in aarch64-apple-darwin x86_64-apple-darwin x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu; do | |
| sha=$(awk '{print $1}' "${target}.sha256") | |
| key=$(echo "$target" | tr '-' '_') | |
| echo "${key}=$sha" >> "$GITHUB_OUTPUT" | |
| done | |
| - name: Update Homebrew tap | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| repository: softwaremill/homebrew-tracevault | |
| event-type: update-formula | |
| client-payload: | | |
| { | |
| "version": "${{ steps.release.outputs.version }}", | |
| "tag": "${{ steps.release.outputs.tag }}", | |
| "sha256_aarch64_apple_darwin": "${{ steps.sha.outputs.aarch64_apple_darwin }}", | |
| "sha256_x86_64_apple_darwin": "${{ steps.sha.outputs.x86_64_apple_darwin }}", | |
| "sha256_x86_64_unknown_linux_gnu": "${{ steps.sha.outputs.x86_64_unknown_linux_gnu }}", | |
| "sha256_aarch64_unknown_linux_gnu": "${{ steps.sha.outputs.aarch64_unknown_linux_gnu }}" | |
| } |