login #19
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package | |
| shell: bash | |
| run: | | |
| set -eux | |
| VERSION="${GITHUB_REF_NAME}" | |
| TARGET="${{ matrix.target }}" | |
| mkdir -p dist | |
| BIN="target/$TARGET/release/canine" | |
| PKG="canine_${VERSION}_${TARGET}" | |
| mkdir -p "$PKG" | |
| cp "$BIN" "$PKG/" | |
| tar -czf "dist/$PKG.tar.gz" "$PKG" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-${{ matrix.target }} | |
| path: dist/*.tar.gz | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| outputs: | |
| sha256_intel: ${{ steps.checksums.outputs.sha256_intel }} | |
| sha256_arm: ${{ steps.checksums.outputs.sha256_arm }} | |
| sha256_source: ${{ steps.checksums.outputs.sha256_source }} | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Flatten and checksum | |
| id: checksums | |
| shell: bash | |
| run: | | |
| set -eux | |
| mkdir -p out | |
| find dist -name "*.tar.gz" -exec cp {} out/ \; | |
| cd out | |
| sha256sum *.tar.gz > SHA256SUMS | |
| echo "sha256_intel=$(grep x86_64-apple-darwin SHA256SUMS | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" | |
| echo "sha256_arm=$(grep aarch64-apple-darwin SHA256SUMS | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" | |
| # Download source tarball and compute SHA256 for Homebrew formula | |
| VERSION="${GITHUB_REF_NAME}" | |
| curl -sL "https://github.com/CanineHQ/cli/archive/refs/tags/${VERSION}.tar.gz" -o source.tar.gz | |
| echo "sha256_source=$(sha256sum source.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| out/*.tar.gz | |
| out/SHA256SUMS | |
| update-homebrew: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| steps: | |
| - name: Update Homebrew formula | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| repository: CanineHQ/homebrew-canine | |
| event-type: update-formula | |
| client-payload: | | |
| { | |
| "version": "${{ github.ref_name }}", | |
| "sha256_intel": "${{ needs.release.outputs.sha256_intel }}", | |
| "sha256_arm": "${{ needs.release.outputs.sha256_arm }}", | |
| "sha256_source": "${{ needs.release.outputs.sha256_source }}" | |
| } |