-
Notifications
You must be signed in to change notification settings - Fork 6
126 lines (106 loc) · 4.3 KB
/
bump-plugin-version.yml
File metadata and controls
126 lines (106 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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