Skip to content

Ai dlc/haiku rebrand/main (#138) #188

Ai dlc/haiku rebrand/main (#138)

Ai dlc/haiku rebrand/main (#138) #188

name: Bump Plugin Version
on:
push:
branches:
- main
paths-ignore:
- "plugin/.claude-plugin/plugin.json"
- ".claude-plugin/marketplace.json"
- "CHANGELOG.md"
- "website/**"
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
permissions:
contents: write
concurrency:
group: version-bump
cancel-in-progress: false
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.BUMP_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: Install Claude CLI
run: npm install -g @anthropic-ai/claude-code
- name: Bump version
id: bump-version
env:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
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 (uses Claude CLI if available, falls back to commit list)
chmod +x .github/scripts/generate-changelog.sh
bash .github/scripts/generate-changelog.sh "." "$NEW_VERSION" "$CURRENT_VERSION"
echo "old_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build MCP server bundle
run: bun run --cwd plugin/mcp-server build
- name: Commit version bump
id: commit
run: |
# Check if there are any changes to commit
if git diff --quiet; then
echo "No version changes to commit"
echo "released=false" >> $GITHUB_OUTPUT
exit 0
fi
# Add version files, changelog, and rebuilt MCP server bundle
git add plugin/.claude-plugin/plugin.json .claude-plugin/marketplace.json CHANGELOG.md plugin/mcp-server/dist/server.mjs
# 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
echo "released=false" >> $GITHUB_OUTPUT
exit 0
fi
# Push the rebased commit
git push origin main
echo "released=true" >> $GITHUB_OUTPUT
- name: Create and push git tag
if: steps.commit.outputs.released == 'true'
run: |
TAG="v${{ steps.bump-version.outputs.new_version }}"
git tag -f "$TAG"
git push -f origin "$TAG"
- name: Package plugin
if: steps.commit.outputs.released == 'true'
run: |
VERSION="${{ steps.bump-version.outputs.new_version }}"
zip -r "ai-dlc-plugin-${VERSION}.zip" plugin/ \
-x "plugin/node_modules/*" \
-x "plugin/*/node_modules/*" \
-x "plugin/*/.tsbuildinfo"
- name: Extract release notes
if: steps.commit.outputs.released == 'true'
run: |
VERSION="${{ steps.bump-version.outputs.new_version }}"
# Extract changelog section for this version
awk -v ver="$VERSION" '
/^## \[/ {
if (found) exit
if (index($0, "[" ver "]") > 0) { found=1; next }
}
found { print }
' CHANGELOG.md > /tmp/release-notes.md
# Convert relative commit links to absolute URLs for release context
sed -i "s|../../commit/|https://github.com/${{ github.repository }}/commit/|g" /tmp/release-notes.md
- name: Create GitHub Release
if: steps.commit.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.bump-version.outputs.new_version }}"
TAG="v${VERSION}"
# Delete existing release on retry to ensure idempotency
gh release delete "$TAG" -y 2>/dev/null || true
gh release create "$TAG" \
--title "$TAG" \
--notes-file /tmp/release-notes.md \
"ai-dlc-plugin-${VERSION}.zip#AI-DLC Plugin (zip)"