-
Notifications
You must be signed in to change notification settings - Fork 4
210 lines (180 loc) · 7.37 KB
/
Copy pathrelease-master.yml
File metadata and controls
210 lines (180 loc) · 7.37 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Release - Master Workflow
# This is the main release workflow that coordinates the entire release process
# It should be triggered manually from the develop branch
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release type'
required: true
type: choice
options:
- patch
- minor
- major
default: 'patch'
dry-run:
description: 'Perform a dry run (no actual release)'
required: false
type: boolean
default: false
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
permissions:
contents: write
pull-requests: write
outputs:
version: ${{ steps.determine-version.outputs.version }}
release-branch: ${{ steps.create-branch.outputs.branch }}
steps:
- name: Checkout develop
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Determine next version
id: determine-version
run: |
# Get current version
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
# Parse version components
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
# Calculate next version based on release type
case "${{ inputs.release-type }}" in
major)
NEXT_VERSION="$((MAJOR + 1)).0.0"
;;
minor)
NEXT_VERSION="$MAJOR.$((MINOR + 1)).0"
;;
patch)
NEXT_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
;;
esac
echo "Next version: $NEXT_VERSION"
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Create release branch
id: create-branch
run: |
BRANCH_NAME="release/v${{ steps.determine-version.outputs.version }}"
git checkout -b "$BRANCH_NAME"
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "Created branch: $BRANCH_NAME"
- name: Update version in files
run: |
# Update version using the existing script
node scripts/update-version.js ${{ steps.determine-version.outputs.version }}
# Generate updated manifest
npm run generate:manifest
# Build to ensure everything compiles
npm run build
chmod +x dist/index.js
- name: Generate or update CHANGELOG
run: |
# Create CHANGELOG.md if it doesn't exist
if [ ! -f CHANGELOG.md ]; then
echo "# Changelog" > CHANGELOG.md
echo "" >> CHANGELOG.md
echo "All notable changes to this project will be documented in this file." >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
# Add new version section
VERSION="${{ steps.determine-version.outputs.version }}"
DATE=$(date +%Y-%m-%d)
# Create temporary file with new entry
echo "## [${VERSION}] - ${DATE}" > CHANGELOG.tmp
echo "" >> CHANGELOG.tmp
echo "### Added" >> CHANGELOG.tmp
echo "- New features go here" >> CHANGELOG.tmp
echo "" >> CHANGELOG.tmp
echo "### Changed" >> CHANGELOG.tmp
echo "- Changes go here" >> CHANGELOG.tmp
echo "" >> CHANGELOG.tmp
echo "### Fixed" >> CHANGELOG.tmp
echo "- Bug fixes go here" >> CHANGELOG.tmp
echo "" >> CHANGELOG.tmp
# Append existing changelog
tail -n +2 CHANGELOG.md >> CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
- name: Create DXT package
run: |
# Install DXT CLI if needed
npm install -g @anthropic-ai/dxt
# Prepare release
node scripts/prepare-release.js ${{ steps.determine-version.outputs.version }}
- name: Commit changes
run: |
git add -A
git commit -m "chore(release): prepare release v${{ steps.determine-version.outputs.version }}"
- name: Push release branch
if: ${{ !inputs.dry-run }}
run: |
git push -u origin "${{ steps.create-branch.outputs.branch }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
- name: Create Pull Request
if: ${{ !inputs.dry-run }}
id: create-pr
run: |
PR_BODY=$(cat <<'EOF'
## 🚀 Release v${{ steps.determine-version.outputs.version }}
### Release Type: ${{ inputs.release-type }}
### Pre-release Checklist
- [ ] Version updated in all files
- [ ] CHANGELOG.md updated
- [ ] Tests passing
- [ ] DXT package created
- [ ] Documentation updated
### Post-merge Actions
After merging this PR, the following will happen automatically:
1. Tag will be created: `v${{ steps.determine-version.outputs.version }}`
2. npm package will be published
3. GitHub release will be created with DXT artifacts
4. Changes will be back-merged to develop
---
*This PR was automatically created by the release workflow.*
EOF
)
PR_URL=$(gh pr create \
--title "Release v${{ steps.determine-version.outputs.version }}" \
--body "$PR_BODY" \
--base main \
--head "${{ steps.create-branch.outputs.branch }}" \
--repo ${{ github.repository }})
echo "Pull request created: $PR_URL"
echo "pr-url=$PR_URL" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
- name: Summary
run: |
echo "## 📦 Release Preparation Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.determine-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Release Type**: ${{ inputs.release-type }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: ${{ steps.create-branch.outputs.branch }}" >> $GITHUB_STEP_SUMMARY
echo "- **Dry Run**: ${{ inputs.dry-run }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ inputs.dry-run }}" = "true" ]; then
echo "⚠️ This was a dry run - no branch or PR was created" >> $GITHUB_STEP_SUMMARY
else
echo "✅ Release branch created and PR opened" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Review and merge the PR: ${{ steps.create-pr.outputs.pr-url }}" >> $GITHUB_STEP_SUMMARY
echo "2. The release will be automatically published after merge" >> $GITHUB_STEP_SUMMARY
fi