Skip to content

Commit 5bfad7d

Browse files
OptimNowclaude
andcommitted
Add auto-tag workflow that fires when plugin.json version bumps on main
Closes the failure mode the repo hit between v1.12 and v1.20.0: plugin.json version was bumped through several PRs (1.13, 1.14, ..., 1.19) without anyone manually tagging, so release.yml never fired and the latest GitHub release zip drifted weeks behind main. Codex flagged this as P1 in its follow-up audit (#75) and the manual fix was to push v1.20.0 by hand. The new workflow .github/workflows/auto-tag-on-plugin-bump.yml runs on every push to main where .claude-plugin/plugin.json changed: 1. Reads the version field via jq, validates it as semver-like (X.Y.Z). 2. Checks whether refs/tags/v<version> already exists - skips if so (handles the case where someone manually pre-tagged). 3. Otherwise creates an annotated tag pointing at the merge commit and pushes it. release.yml then auto-fires from the new tag and publishes cloud-finops-v<version>.zip. Permissions: contents: write (needed to push the tag). The default GITHUB_TOKEN is sufficient. Operational note: the tag is created by github-actions[bot] so the commit history shows the bot as the tagger. The release body is still auto- populated by release.yml's generate_release_notes flag, so the human- visible release page gets the usual PR / commit summary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7ad3470 commit 5bfad7d

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Auto-tag on plugin.json bump
2+
3+
# When a push to main changes .claude-plugin/plugin.json, read the version
4+
# field and create a matching v<version> tag if one does not already exist.
5+
# Pushing the tag triggers release.yml, which produces the cloud-finops-
6+
# v<version>.zip artefact.
7+
#
8+
# This closes the failure mode the cloud-finops-skills repo hit between
9+
# v1.12 and v1.20.0: the plugin.json version was bumped through several PRs
10+
# (1.13, 1.14, ..., 1.19) without anyone manually tagging, so release.yml
11+
# never fired and the latest release zip drifted weeks behind main.
12+
13+
on:
14+
push:
15+
branches: [main]
16+
paths:
17+
- '.claude-plugin/plugin.json'
18+
19+
permissions:
20+
contents: write # required to push the new tag
21+
22+
jobs:
23+
tag-from-plugin-version:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout main
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0 # need full history so `git tag` sees existing tags
30+
31+
- name: Read version from plugin.json
32+
id: read_version
33+
run: |
34+
set -euo pipefail
35+
version=$(jq -r '.version' .claude-plugin/plugin.json)
36+
if [[ -z "$version" || "$version" == "null" ]]; then
37+
echo "::error::plugin.json has no .version field"
38+
exit 1
39+
fi
40+
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
41+
echo "::error::plugin.json .version=$version is not semver-like (X.Y.Z)"
42+
exit 1
43+
fi
44+
echo "version=$version" >> "$GITHUB_OUTPUT"
45+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
46+
47+
- name: Skip if tag already exists
48+
id: check_tag
49+
run: |
50+
set -euo pipefail
51+
tag="${{ steps.read_version.outputs.tag }}"
52+
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null 2>&1; then
53+
echo "Tag $tag already exists, nothing to do."
54+
echo "skip=true" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "Tag $tag does not exist yet."
57+
echo "skip=false" >> "$GITHUB_OUTPUT"
58+
fi
59+
60+
- name: Create and push tag
61+
if: steps.check_tag.outputs.skip == 'false'
62+
run: |
63+
set -euo pipefail
64+
tag="${{ steps.read_version.outputs.tag }}"
65+
version="${{ steps.read_version.outputs.version }}"
66+
67+
git config user.name "github-actions[bot]"
68+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
69+
70+
# Build a tag message that points at plugin.json as the source of truth
71+
# for what changed. The release.yml workflow uses generate_release_notes
72+
# so the user-facing release body still gets auto-populated from the
73+
# commits between this tag and the previous one.
74+
git tag -a "$tag" -m "Auto-tagged from .claude-plugin/plugin.json bump to $version
75+
76+
This tag was created automatically by .github/workflows/auto-tag-on-plugin-bump.yml
77+
when plugin.json on main moved to version $version.
78+
79+
The release.yml workflow will fire from this tag and publish
80+
cloud-finops-${tag}.zip to a new GitHub release."
81+
82+
git push origin "$tag"
83+
echo "Pushed tag $tag - release.yml will produce cloud-finops-${tag}.zip"

0 commit comments

Comments
 (0)