lucy-cli 1.6.1

A small local JSONL agent harness
Documentation
name: Version bump

on:
  push:
    branches:
      - main

permissions:
  contents: write

concurrency:
  group: version-bump-main
  cancel-in-progress: false

jobs:
  bump:
    if: ${{ !startsWith(github.event.head_commit.message, 'chore(release):') }}
    runs-on: ubuntu-22.04
    outputs:
      release: ${{ steps.bump.outputs.release }}
      ref: ${{ steps.bump.outputs.ref }}
      tag: ${{ steps.bump.outputs.tag }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          persist-credentials: true

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Install release-plz
        uses: taiki-e/install-action@v2.82.10
        with:
          tool: release-plz@0.3.160

      - name: Bump version and create release tag
        id: bump
        shell: bash
        run: |
          set -euo pipefail

          release=false
          version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "lucy-cli") | .version')"
          latest_tag="$(git tag --sort=-version:refname --list 'v*' | head -n1)"

          if [[ -z "$latest_tag" ]]; then
            if [[ "$version" != "1.0.0" ]]; then
              echo "initial release must start at 1.0.0, found ${version}" >&2
              exit 1
            fi
            release=true
          else
            latest_version="${latest_tag#v}"
            if [[ "$version" != "$latest_version" ]]; then
              echo "lucy-cli package version ${version} does not match latest release tag ${latest_tag}" >&2
              exit 1
            fi

            release-plz update --config release-plz.toml
            git add Cargo.toml Cargo.lock CHANGELOG.md
            if ! git diff --cached --quiet; then
              release=true
              version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "lucy-cli") | .version')"
              if [[ "$version" == "$latest_version" ]]; then
                echo "release-plz did not advance lucy-cli beyond ${latest_tag}" >&2
                exit 1
              fi
            fi
          fi

          if [[ "$release" != true ]]; then
            echo "no Conventional Commit requires a release"
            {
              echo "release=false"
              echo "ref=$(git rev-parse HEAD)"
              echo "tag="
            } >> "$GITHUB_OUTPUT"
            exit 0
          fi

          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add Cargo.toml Cargo.lock CHANGELOG.md
          git commit --allow-empty -m "chore(release): v${version}"
          tag="v${version}"
          git tag --annotate "$tag" --message "Release ${version}"
          git push origin HEAD:main "refs/tags/${tag}"

          {
            echo "release=true"
            echo "ref=$(git rev-parse HEAD)"
            echo "tag=$tag"
          } >> "$GITHUB_OUTPUT"

  release:
    needs: bump
    if: ${{ needs.bump.outputs.release == 'true' }}
    uses: ./.github/workflows/release.yml
    with:
      ref: ${{ needs.bump.outputs.ref }}
      tag: ${{ needs.bump.outputs.tag }}
    secrets: inherit