Skip to content

Auto-bump patch version on PR merge #1

Auto-bump patch version on PR merge

Auto-bump patch version on PR merge #1

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:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump patch version
id: bump
run: |
CURRENT=$(jq -r '.version' .claude-plugin/plugin.json)
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "Bumping $CURRENT → $NEW_VERSION"
# Update plugin.json
jq --arg v "$NEW_VERSION" '.version = $v' .claude-plugin/plugin.json > tmp.json && mv tmp.json .claude-plugin/plugin.json
# Update manifest.json
jq --arg v "$NEW_VERSION" '.version = $v' manifest.json > tmp.json && mv tmp.json manifest.json
- name: Commit version bump
run: |
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
git commit -m "bump to v${{ steps.bump.outputs.version }}"
git push
- name: Generate release notes
id: notes
run: |
VERSION="${{ steps.bump.outputs.version }}"
NOTES=$(awk "/^## ${VERSION}$/,/^## /{if(/^## ${VERSION}$/)next; if(/^## /)exit; print}" CHANGELOG.md 2>/dev/null)
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.bump.outputs.version }}"
git tag "$TAG"
git push origin "$TAG"
gh release create "$TAG" --title "$TAG" --notes "${{ steps.notes.outputs.notes }}"