refquiem 0.3.4

A cargo requiem for the refs your Rust code left behind
Documentation
name: Action Release

on:
  push:
    tags:
      - "v*.*"
  release:
    types: [published]

permissions:
  contents: write

jobs:
  release:
    name: Maintain the action release
    runs-on: ubuntu-26.04
    steps:
      - uses: actions/checkout@v4

      - name: Check the tag is an action release
        id: check
        # The Release workflow owns the crate version tags.
        run: |
          manifest="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "refquiem") | .version')"
          tag="${GITHUB_REF_NAME#v}"
          if [ "$tag" = "$manifest" ]; then
            echo "tag $GITHUB_REF_NAME is the crate version $manifest, the Release workflow owns it"
            echo "action=false" >> "$GITHUB_OUTPUT"
          else
            echo "action=true" >> "$GITHUB_OUTPUT"
          fi

      - name: Create the release
        if: github.event_name == 'push' && steps.check.outputs.action == 'true'
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes

      - name: Move the major tag
        # The major tag, such as v1, points at the newest release of its series.
        if: steps.check.outputs.action == 'true'
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          major="${GITHUB_REF_NAME#v}"
          major="${major%%.*}"
          url="repos/$GITHUB_REPOSITORY/git/refs/tags/v$major"
          if gh api "$url" >/dev/null 2>&1; then
            gh api "$url" -X PATCH -f "sha=$GITHUB_SHA" -F "force=true"
          else
            gh api "repos/$GITHUB_REPOSITORY/git/refs" -X POST -f "ref=refs/tags/v$major" -f "sha=$GITHUB_SHA"
          fi