bashers 0.8.8

Installable cli helpers
Documentation
name: Release-plz

on:
  push:
    branches:
      - main

jobs:

  test:
    name: Test
    runs-on: ubuntu-latest
    if: "startsWith(github.event.head_commit.message, 'chore: release') == false"
    steps:
      - uses: actions/checkout@v6
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-
      - name: Check
        run: cargo check
      - name: Build
        run: cargo build --verbose
      - name: Install cargo-tarpaulin
        run: cargo install cargo-tarpaulin --locked --force
      - name: Coverage
        run: cargo tarpaulin --lib --out Xml --output-dir coverage --timeout 120
      - name: Clippy
        run: cargo clippy -- -D warnings

  release-plz-pr:
    name: Release-plz PR
    runs-on: ubuntu-latest
    needs: [test]
    if: "startsWith(github.event.head_commit.message, 'chore: release') == false"
    environment: Rust Push
    permissions:
      contents: write
      pull-requests: write
    concurrency:
      group: release-plz-${{ github.ref }}
      cancel-in-progress: false
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          persist-credentials: true
          token: ${{ secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }}
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      - name: Run release-plz
        id: release-plz
        uses: release-plz/action@v0.5
        with:
          command: release-pr
        env:
          GITHUB_TOKEN: ${{ secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }}
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
      - name: Sync pyproject.toml version to release PR
        if: steps.release-plz.outputs.pr != ''
        env:
          GH_TOKEN: ${{ secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }}
          PR_JSON: ${{ steps.release-plz.outputs.pr }}
        run: |
          PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number')
          if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" = 'null' ]; then
            exit 0
          fi
          gh pr checkout "$PR_NUMBER"
          VERSION=$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -1)
          if [ -n "$VERSION" ]; then
            sed -i "s/^version = \".*\"$/version = \"$VERSION\"/" pyproject.toml
            git add pyproject.toml
            if git diff --staged --quiet; then
              echo "pyproject.toml already at version $VERSION"
            else
              git config user.name "github-actions[bot]"
              git config user.email "github-actions[bot]@users.noreply.github.com"
              git commit -m "chore: sync pyproject.toml version with Cargo.toml"
              git push
            fi
          fi
      - name: Merge release PR
        if: steps.release-plz.outputs.pr != ''
        env:
          GH_TOKEN: ${{ secrets.GIT_TOKEN || secrets.GITHUB_TOKEN }}
          PR_JSON: ${{ steps.release-plz.outputs.pr }}
        run: |
          PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number')
          if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != 'null' ]; then
            gh pr merge "$PR_NUMBER" --squash
          fi