brake 2026.11.3

A brake on breaking API changes. Checks OpenAPI, protobuf and GraphQL contracts for backward compatibility, hermetically.
Documentation
# Standard release workflow for grahambrooks Rust tools (release-kit v2).
#
# This file and scripts/release.py are byte-identical in every repo; everything
# repo-specific lives in .release.env. Re-sync with release-kit/stamp.sh.
#
# The tag is the version. Push a CalVer tag (vYYYY.M.N) — by hand, or let
# auto-managed's monthly job create it — and this workflow:
#   1. plans the build from .release.env and the tag,
#   2. makes sure a GitHub Release exists for the tag (auto-managed creates one),
#   3. stamps the tag's version into Cargo.toml (and the workspace's own entries
#      in a committed Cargo.lock) and builds every target — with --locked when
#      Cargo.lock is committed, so a release ships the dependencies CI tested —
#      uploading <bin>-<tag>-<target>.tar.gz (.zip on Windows) with the binaries
#      at the archive root — the layout bx and Homebrew both expect,
#   4. publishes SHA256SUMS, then opens and merges one PR that updates the in-repo
#      Homebrew formula and bumps Cargo.toml to the released version,
#   5. optionally publishes to crates.io (PUBLISH_CRATE=true), last, because it is
#      the one step that cannot be undone.
#
# Re-run a tag (e.g. after fixing a runner problem): Actions → release → Run
# workflow, with the tag. The tag must already contain this workflow.
name: release

on:
  push:
    tags:
      - 'v*.*.*'
  workflow_dispatch:
    inputs:
      tag:
        description: Existing tag to build and publish (e.g. v2026.9.3)
        required: true

permissions:
  contents: read

concurrency:
  group: release-${{ inputs.tag || github.ref_name }}
  cancel-in-progress: false

env:
  CARGO_TERM_COLOR: always
  TAG: ${{ inputs.tag || github.ref_name }}

jobs:
  plan:
    name: plan
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.plan.outputs.version }}
      matrix: ${{ steps.plan.outputs.matrix }}
      archive: ${{ steps.plan.outputs.archive }}
      bins: ${{ steps.plan.outputs.bins }}
      package: ${{ steps.plan.outputs.package }}
      features: ${{ steps.plan.outputs.features }}
      manifest_path: ${{ steps.plan.outputs.manifest_path }}
      publish_crate: ${{ steps.plan.outputs.publish_crate }}
      locked: ${{ steps.plan.outputs.locked }}
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ env.TAG }}
      - id: plan
        env:
          REPO_PRIVATE: ${{ github.event.repository.private }}
        run: python3 scripts/release.py plan "$TAG"

  release:
    name: ensure github release
    needs: plan
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          if gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
            echo "Release $TAG already exists"
          else
            gh release create "$TAG" -R "$GITHUB_REPOSITORY" --verify-tag --title "$TAG" --generate-notes
          fi

  build:
    name: build (${{ matrix.target }})
    needs: [plan, release]
    runs-on: ${{ matrix.os }}
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ env.TAG }}
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      # A rust-toolchain.toml overrides the stable toolchain above, and that pinned
      # toolchain needs the target too (cross-compiled targets fail without it).
      - name: Add ${{ matrix.target }} to the pinned toolchain
        shell: bash
        working-directory: ${{ matrix.workspace }}
        run: |
          set -euo pipefail
          rustup toolchain install --no-self-update
          rustup target add "${{ matrix.target }}"
      - uses: Swatinem/rust-cache@v2
        with:
          key: release-${{ matrix.target }}
          workspaces: ${{ matrix.workspace }}
      - name: Stamp version ${{ needs.plan.outputs.version }}
        run: python3 scripts/release.py set-version "${{ needs.plan.outputs.version }}"
      - name: Build, package, and upload
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: ${{ needs.plan.outputs.bins }}
          package: ${{ needs.plan.outputs.package }}
          features: ${{ needs.plan.outputs.features }}
          manifest-path: ${{ needs.plan.outputs.manifest_path }}
          target: ${{ matrix.target }}
          locked: ${{ needs.plan.outputs.locked }}
          archive: ${{ needs.plan.outputs.archive }}
          tar: unix
          zip: windows
          ref: refs/tags/${{ env.TAG }}
          token: ${{ github.token }}

  finalize:
    name: checksums + formula
    needs: [plan, build]
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ github.event.repository.default_branch }}
      - name: Publish SHA256SUMS
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          mkdir -p "$RUNNER_TEMP/dist"
          gh release download "$TAG" -R "$GITHUB_REPOSITORY" -D "$RUNNER_TEMP/dist" -p '*.tar.gz' -p '*.zip'
          python3 scripts/release.py sums "$RUNNER_TEMP/dist" > "$RUNNER_TEMP/SHA256SUMS"
          cat "$RUNNER_TEMP/SHA256SUMS"
          gh release upload "$TAG" -R "$GITHUB_REPOSITORY" "$RUNNER_TEMP/SHA256SUMS" --clobber
      - name: Render formula and bump Cargo.toml
        run: |
          set -euo pipefail
          python3 scripts/release.py formula "$TAG" "$RUNNER_TEMP/SHA256SUMS"
          python3 scripts/release.py set-version "${{ needs.plan.outputs.version }}"
      # The automation-guard ruleset only lets changes reach the default branch
      # through a pull request; it asks for no approvals or checks, so opening and
      # merging one satisfies it rather than working around it.
      - name: Open and merge release PR
        env:
          GH_TOKEN: ${{ github.token }}
          BASE: ${{ github.event.repository.default_branch }}
        run: |
          set -euo pipefail
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add -A
          if git diff --cached --quiet; then
            echo "Formula and version already current"
            exit 0
          fi
          title="Release ${TAG}: update Homebrew formula and version"
          # A fresh branch per attempt: a re-run must not force-push or delete a
          # branch, which a ruleset covering all branches (non_fast_forward,
          # deletion) refuses.
          branch="release/${TAG}"
          if git ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then
            branch="release/${TAG}-${GITHUB_RUN_ID}"
          fi
          git checkout -b "$branch"
          git commit -m "$title"
          git push origin "$branch"
          pr=$(gh pr list --head "$branch" --state open --json number -q '.[0].number // empty')
          if [ -z "$pr" ]; then
            pr=$(gh pr create --base "$BASE" --head "$branch" --title "$title" \
                   --body "Generated by the release workflow from the published ${TAG} assets." \
                 | awk -F/ '{print $NF}')
          fi
          # Deleting the branch is a convenience; a deletion rule may forbid it.
          gh pr merge "$pr" --squash --delete-branch || \
          if ! gh pr merge "$pr" --squash; then
            state=$(gh pr view "$pr" --json state -q .state)
            if [ "$state" != "MERGED" ]; then
              echo "::error::release PR #${pr} could not be merged (state=${state})"
              exit 1
            fi
          fi

  publish-crate:
    name: publish to crates.io
    needs: [plan, finalize]
    if: needs.plan.outputs.publish_crate == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ env.TAG }}
      - uses: dtolnay/rust-toolchain@stable
      - name: Publish unless already published
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          set -euo pipefail
          if [ -z "${CARGO_REGISTRY_TOKEN}" ]; then
            echo "::error::PUBLISH_CRATE=true but the CARGO_REGISTRY_TOKEN secret is not set"
            exit 1
          fi
          python3 scripts/release.py set-version "${{ needs.plan.outputs.version }}"
          python3 scripts/release.py publish-crate "${{ needs.plan.outputs.version }}"