rulewright 0.1.2

Executable engineering standards for Rust workspaces
Documentation
name: Release to crates.io

on:
  push:
    tags:
      - "v*"

permissions:
  contents: read
  id-token: write

concurrency:
  group: crates-io-release
  cancel-in-progress: false

env:
  CARGO_TERM_COLOR: always

jobs:
  publish:
    name: Verify and publish
    runs-on: ubuntu-latest
    environment: crates-io
    steps:
      - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
        with:
          fetch-depth: 0
      - name: Test release contract
        run: bash scripts/test-release.sh
      - name: Verify tagged commit belongs to main
        run: bash scripts/verify-release-commit.sh origin main "${GITHUB_REF_NAME}"
      - name: Verify tag matches package version
        shell: bash
        run: |
          version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "rulewright") | .version')"
          test "${GITHUB_REF_NAME}" = "v${version}"
      - uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
            examples/custom-rule-pack/target
          key: release-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml', 'Cargo.lock', 'examples/custom-rule-pack/Cargo.toml') }}
      - run: cargo fmt --all -- --check
      - run: cargo clippy --workspace --all-targets --locked -- -D warnings
      - run: cargo test --workspace --all-targets --locked
      - name: Build documentation
        env:
          RUSTDOCFLAGS: -D warnings
        run: cargo doc --workspace --no-deps --locked
      - run: cargo run --locked -- --strict
      - run: cargo test --manifest-path examples/custom-rule-pack/Cargo.toml --locked
      - run: cargo package --list --locked
      - run: cargo package --locked
      - name: Test extracted package
        shell: bash
        run: |
          package_dir="$(find target/package -mindepth 1 -maxdepth 1 -type d -name 'rulewright-*' | sort | tail -n 1)"
          test -n "${package_dir}"
          cargo test --manifest-path "${package_dir}/Cargo.toml" --all-targets --locked
      - name: Authenticate with crates.io
        id: crates-io-auth
        uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
        run: cargo publish --locked