Skip to content

fix(plugin): enforce full unit display during elaboration review #45

fix(plugin): enforce full unit display during elaboration review

fix(plugin): enforce full unit display during elaboration review #45

name: Bump Plugin Version
on:
push:
branches:
- main
paths-ignore:
- "plugin/.claude-plugin/plugin.json"
- ".claude-plugin/marketplace.json"
- "CHANGELOG.md"
- "website/**"
permissions:
contents: write
jobs:
bump-version:
runs-on: ubuntu-latest
# Skip if commit is from bot (prevent loops) or if it's a version bump commit
if: |
github.actor != 'github-actions[bot]' &&
!contains(github.event.head_commit.message, '[skip ci]')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Pull latest changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git pull --rebase origin main
- name: Determine version bump type
id: bump-type
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
# Check for breaking changes (major bump)
if echo "$COMMIT_MSG" | grep -qE '^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then
echo "type=major" >> $GITHUB_OUTPUT
echo "Detected: MAJOR (breaking change)"
# Check for features (minor bump)
elif echo "$COMMIT_MSG" | grep -qE '^feat(\(.+\))?:'; then
echo "type=minor" >> $GITHUB_OUTPUT
echo "Detected: MINOR (new feature)"
# Everything else (patch bump) - fix, chore, docs, refactor, etc.
else
echo "type=patch" >> $GITHUB_OUTPUT
echo "Detected: PATCH (fix/chore/other)"
fi
- name: Bump version
id: bump-version
run: |
BUMP_TYPE="${{ steps.bump-type.outputs.type }}"
PLUGIN_JSON="plugin/.claude-plugin/plugin.json"
MARKETPLACE_JSON=".claude-plugin/marketplace.json"
# Get current version
CURRENT_VERSION=$(jq -r '.version' "$PLUGIN_JSON")
echo "Current version: $CURRENT_VERSION"
# Parse version components
MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1)
MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2)
PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3)
# Bump based on type
case "$BUMP_TYPE" in
major)
NEW_VERSION="$((MAJOR + 1)).0.0"
;;
minor)
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
;;
patch)
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
;;
esac
echo "New version: $NEW_VERSION"
# Update plugin.json
jq --arg version "$NEW_VERSION" '.version = $version' "$PLUGIN_JSON" > "$PLUGIN_JSON.tmp"
mv "$PLUGIN_JSON.tmp" "$PLUGIN_JSON"
# Update marketplace.json metadata.version
jq --arg version "$NEW_VERSION" '.metadata.version = $version' "$MARKETPLACE_JSON" > "$MARKETPLACE_JSON.tmp"
mv "$MARKETPLACE_JSON.tmp" "$MARKETPLACE_JSON"
# Generate changelog
chmod +x .github/scripts/generate-changelog.sh
.github/scripts/generate-changelog.sh "." "$NEW_VERSION" "$CURRENT_VERSION"
echo "old_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Commit version bump
run: |
# Check if there are any changes to commit
if git diff --quiet; then
echo "No version changes to commit"
exit 0
fi
# Add version files and changelog
git add plugin/.claude-plugin/plugin.json .claude-plugin/marketplace.json CHANGELOG.md
# Create commit message
COMMIT_MSG="chore(plugin): bump version ${{ steps.bump-version.outputs.old_version }} -> ${{ steps.bump-version.outputs.new_version }} [skip ci]"
git commit -m "$COMMIT_MSG"
# Pull latest and rebase, handling conflicts gracefully
if ! git pull --rebase origin main; then
echo "Rebase conflict detected - another workflow likely pushed first"
echo "Aborting rebase and exiting cleanly (next push will retry)"
git rebase --abort 2>/dev/null || true
exit 0
fi
# Push the rebased commit
git push origin main