ci(release): fail fast on publish errors #2
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 | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| triple: linux-x86_64 | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| triple: linux-aarch64 | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| triple: darwin-x86_64 | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| triple: darwin-aarch64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Build | |
| run: cargo build --workspace --release --target ${{ matrix.target }} | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| - name: Strip binary | |
| run: | | |
| strip target/${{ matrix.target }}/release/acb || true | |
| strip target/${{ matrix.target }}/release/acb-mcp || true | |
| - name: Package | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| ASSET="agentic-codebase-${VERSION}-${{ matrix.triple }}" | |
| mkdir -p "${ASSET}" | |
| cp target/${{ matrix.target }}/release/acb "${ASSET}/" | |
| cp target/${{ matrix.target }}/release/acb-mcp "${ASSET}/" | |
| tar czf "${ASSET}.tar.gz" "${ASSET}" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: agentic-codebase-${{ matrix.triple }} | |
| path: "*.tar.gz" | |
| release: | |
| name: Create Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: artifacts/**/*.tar.gz | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') }} | |
| publish-crate: | |
| name: Publish to crates.io (acb + acb-mcp) | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Publish agentic-codebase crate | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if ! output="$(cargo publish --token "${{ secrets.CARGO_REGISTRY_TOKEN }}" 2>&1)"; then | |
| echo "$output" | |
| if echo "$output" | grep -qi "already uploaded"; then | |
| echo "agentic-codebase already published for this version; continuing." | |
| else | |
| exit 1 | |
| fi | |
| else | |
| echo "$output" | |
| fi |