fix(#163): fold comments into hunt Step 2 pr-list call (#164) #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cuts a Git tag and a GitHub Release whenever .claude-plugin/plugin.json | |
| # `version` changes on master. The release notes are auto-generated by | |
| # GitHub from the PRs merged since the previous tag. | |
| # | |
| # Implementation choice: pure shell + jq + `gh release create --generate-notes`. | |
| # Considered release-please and softprops/action-gh-release; chose shell so | |
| # the policy is one short readable file with no third-party dependency. If a | |
| # future requirement (e.g. monorepo per-package versioning, custom notes | |
| # template) outgrows this, swap in release-please at that point. | |
| name: Release on version change | |
| on: | |
| push: | |
| # List both master and main so a future default-branch rename does | |
| # not silently stop publishing releases. GitHub Actions does not | |
| # template `branches:`, so a literal list is the simplest correct | |
| # shape. | |
| branches: [master, main] | |
| paths: ['.claude-plugin/plugin.json'] | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout with previous commit | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Detect version change | |
| id: detect | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| new_version=$(jq -r .version .claude-plugin/plugin.json) | |
| old_version=$(git show HEAD~1:.claude-plugin/plugin.json 2>/dev/null \ | |
| | jq -r .version 2>/dev/null || echo "") | |
| echo "old_version=$old_version" | |
| echo "new_version=$new_version" | |
| if [ -z "$new_version" ] || [ "$new_version" = "null" ]; then | |
| echo "::error file=.claude-plugin/plugin.json::Could not parse version field" | |
| exit 1 | |
| fi | |
| if [ "$new_version" = "$old_version" ]; then | |
| echo "Version unchanged ($new_version); nothing to release." | |
| echo "should_release=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| tag="v${new_version}" | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| echo "should_release=true" >> "$GITHUB_OUTPUT" | |
| - name: Verify tag does not already exist | |
| if: steps.detect.outputs.should_release == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG: ${{ steps.detect.outputs.tag }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if gh api "repos/${{ github.repository }}/git/refs/tags/${TAG}" >/dev/null 2>&1; then | |
| echo "::error::Tag ${TAG} already exists on remote — skipping release." | |
| echo "Likely cause: this version was already released manually. If the" | |
| echo "intent was to re-release, delete the tag first or bump again." | |
| exit 1 | |
| fi | |
| - name: Create tag and GitHub Release | |
| if: steps.detect.outputs.should_release == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| TAG: ${{ steps.detect.outputs.tag }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| gh release create "${TAG}" \ | |
| --target "${GITHUB_SHA}" \ | |
| --title "${TAG}" \ | |
| --generate-notes | |
| echo "Released ${TAG}: $(gh release view "${TAG}" --json url --jq .url)" |