Skip to content

Fix v2.0.1: migrate commands/ to skills/, fix manifest version #6

Fix v2.0.1: migrate commands/ to skills/, fix manifest version

Fix v2.0.1: migrate commands/ to skills/, fix manifest version #6

Workflow file for this run

name: Release
on:
pull_request:
types: [closed]
branches: [main]
jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.VERSION_BUMP_KEY }}
fetch-depth: 0
- name: Determine version
id: version
run: |
MANIFEST_VERSION=$(jq -r '.version' manifest.json)
PLUGIN_VERSION=$(jq -r '.version' .claude-plugin/plugin.json)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
echo "manifest=$MANIFEST_VERSION plugin=$PLUGIN_VERSION latest_tag=$LATEST_TAG"
# If manifest version is ahead of the latest tag, use it (manual bump)
if [ "$MANIFEST_VERSION" != "$LATEST_TAG" ] && [ "$MANIFEST_VERSION" != "$PLUGIN_VERSION" ] || [ "$MANIFEST_VERSION" != "$LATEST_TAG" ]; then
# Check if manifest version is actually newer
MANIFEST_MAJOR=$(echo "$MANIFEST_VERSION" | cut -d. -f1)
MANIFEST_MINOR=$(echo "$MANIFEST_VERSION" | cut -d. -f2)
MANIFEST_PATCH=$(echo "$MANIFEST_VERSION" | cut -d. -f3)
TAG_MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1)
TAG_MINOR=$(echo "$LATEST_TAG" | cut -d. -f2)
TAG_PATCH=$(echo "$LATEST_TAG" | cut -d. -f3)
if [ "$MANIFEST_MAJOR" -gt "$TAG_MAJOR" ] 2>/dev/null || \
([ "$MANIFEST_MAJOR" -eq "$TAG_MAJOR" ] && [ "$MANIFEST_MINOR" -gt "$TAG_MINOR" ]) 2>/dev/null || \
([ "$MANIFEST_MAJOR" -eq "$TAG_MAJOR" ] && [ "$MANIFEST_MINOR" -eq "$TAG_MINOR" ] && [ "$MANIFEST_PATCH" -gt "$TAG_PATCH" ]) 2>/dev/null; then
echo "Manual version bump detected: $LATEST_TAG → $MANIFEST_VERSION"
echo "version=$MANIFEST_VERSION" >> "$GITHUB_OUTPUT"
echo "bumped=manual" >> "$GITHUB_OUTPUT"
else
echo "Manifest version $MANIFEST_VERSION is not ahead of tag $LATEST_TAG — auto-bumping patch"
echo "bumped=auto" >> "$GITHUB_OUTPUT"
fi
else
echo "No manual bump — auto-bumping patch"
echo "bumped=auto" >> "$GITHUB_OUTPUT"
fi
# Auto-bump patch if no manual bump was set
if ! grep -q "version=" "$GITHUB_OUTPUT" 2>/dev/null; then
MAJOR=$(echo "$LATEST_TAG" | cut -d. -f1)
MINOR=$(echo "$LATEST_TAG" | cut -d. -f2)
PATCH=$(echo "$LATEST_TAG" | cut -d. -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "Auto-bumping: $LATEST_TAG → $NEW_VERSION"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
fi
- name: Sync version files
run: |
VERSION="${{ steps.version.outputs.version }}"
jq --arg v "$VERSION" '.version = $v' .claude-plugin/plugin.json > tmp.json && mv tmp.json .claude-plugin/plugin.json
jq --arg v "$VERSION" '.version = $v' manifest.json > tmp.json && mv tmp.json manifest.json
- name: Commit version bump
run: |
VERSION="${{ steps.version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .claude-plugin/plugin.json manifest.json
# Only commit if there are changes
if git diff --cached --quiet; then
echo "Version files already at $VERSION — no commit needed"
else
git commit -m "bump to v${VERSION}"
git push
fi
- name: Generate release notes
id: notes
run: |
VERSION="${{ steps.version.outputs.version }}"
NOTES=$(awk "/^## ${VERSION}$/,/^## /{if(/^## ${VERSION}$/)next; if(/^## /)exit; print}" CHANGELOG.md 2>/dev/null)
if [ -z "$NOTES" ]; then
# Try with v prefix
NOTES=$(awk "/^## v${VERSION}$/,/^## /{if(/^## v${VERSION}$/)next; if(/^## /)exit; print}" CHANGELOG.md 2>/dev/null)
fi
if [ -z "$NOTES" ]; then
NOTES="Merged: ${{ github.event.pull_request.title }}"
fi
{
echo "notes<<EOF"
echo "$NOTES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create tag and release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ steps.version.outputs.version }}"
if git ls-remote --tags origin "refs/tags/$TAG" | grep -q "$TAG"; then
echo "Tag $TAG already exists — skipping release"
exit 0
fi
git tag "$TAG"
git push origin "$TAG"
gh release create "$TAG" --title "$TAG" --notes "${{ steps.notes.outputs.notes }}"