Skip to content

Commit b5b4b51

Browse files
fix: improve release script for branch protection workflow - Add --tag flag to automate tag creation after PR merge - Improve error messages and validation - Add troubleshooting section for missing tags - Enhance user experience with better colors and instructions (#78)
* fix: improve release script for branch protection workflow - Add --tag flag to automate tag creation after PR merge - Improve error messages and validation - Add troubleshooting section for missing tags - Enhance user experience with better colors and instructions * feat: add GitHub Release creation to release workflow - Automatically create GitHub releases with VSIX attachments - Generate release notes automatically - Make releases easily downloadable for users
1 parent 605f326 commit b5b4b51

File tree

3 files changed

+106
-16
lines changed

3 files changed

+106
-16
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ jobs:
5050
path: "*.vsix"
5151
retention-days: 30
5252

53+
- name: Create GitHub Release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
files: "*.vsix"
57+
generate_release_notes: true
58+
draft: false
59+
prerelease: false
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
5363
# Optional: Uncomment and add VSCE_PAT secret to enable marketplace publishing
5464
# - name: Publish to Marketplace (optional)
5565
# if: ${{ secrets.VSCE_PAT }}

RELEASE.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ git push origin release/v0.1.3
3737
# 5. After PR is merged, create and push the tag:
3838
git checkout main
3939
git pull origin main
40-
git tag v0.1.3
41-
git push origin v0.1.3
40+
./scripts/release.sh --tag 0.1.3
4241
```
4342

43+
**💡 Pro tip**: The `--tag` flag automates the tag creation and push, ensuring the release workflow triggers correctly.
44+
4445
### For Direct Main Access
4546

4647
If you have direct push access to main:
@@ -135,10 +136,12 @@ When you push a tag matching `v*`, the GitHub Actions workflow will:
135136
The extension requires a `publisher` field in `package.json` for packaging. Currently set to `stepzen-dev` for development builds.
136137

137138
### For Development/Internal Releases
139+
138140
- Keep `"publisher": "stepzen-dev"` for internal testing and development
139141
- VSIX files can be installed manually via "Install from VSIX..." in VS Code
140142

141143
### For Official IBM Publishing
144+
142145
When ready for official IBM marketplace publishing:
143146

144147
1. Update `package.json` publisher to the official IBM publisher ID
@@ -164,6 +167,21 @@ Follow [Semantic Versioning](https://semver.org/):
164167

165168
## Troubleshooting
166169

170+
### Release Workflow Not Triggering
171+
172+
If you merged a version bump PR but the release workflow didn't run:
173+
174+
```bash
175+
# Check if the tag exists
176+
git tag --list | grep v0.1.3
177+
178+
# If no tag exists, create it (ensure you're on main with latest changes)
179+
git checkout main && git pull origin main
180+
./scripts/release.sh --tag 0.1.3
181+
```
182+
183+
**Root cause**: The release workflow only triggers on tag pushes (`v*`), not on regular commits or PR merges.
184+
167185
### Version Mismatch Error
168186

169187
If the workflow fails with a version mismatch:

scripts/release.sh

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
# Assisted by CursorAI
55

66
# Release helper script for vscode-stepzen extension
7-
# Usage: ./scripts/release.sh [version]
8-
# Example: ./scripts/release.sh 0.1.3
7+
# Usage:
8+
# ./scripts/release.sh [version] - Create release branch and bump version
9+
# ./scripts/release.sh --tag [version] - Create and push tag after PR merge
10+
# Examples:
11+
# ./scripts/release.sh 0.1.3 - Start release process
12+
# ./scripts/release.sh --tag 0.1.3 - Complete release by creating tag
913

1014
set -e
1115

1216
# Colors for output
1317
RED='\033[0;31m'
1418
GREEN='\033[0;32m'
1519
YELLOW='\033[1;33m'
20+
BLUE='\033[0;34m'
1621
NC='\033[0m' # No Color
1722

1823
# Function to print colored output
@@ -28,6 +33,64 @@ print_error() {
2833
echo -e "${RED}$1${NC}"
2934
}
3035

36+
print_step() {
37+
echo -e "${BLUE}🔄 $1${NC}"
38+
}
39+
40+
# Function to create and push tag
41+
create_and_push_tag() {
42+
local version=$1
43+
44+
# Validate we're on main and up to date
45+
CURRENT_BRANCH=$(git branch --show-current)
46+
if [ "$CURRENT_BRANCH" != "main" ]; then
47+
print_error "Must be on main branch to create release tag"
48+
print_info "Run: git checkout main && git pull origin main"
49+
exit 1
50+
fi
51+
52+
# Check if working directory is clean
53+
if ! git diff-index --quiet HEAD --; then
54+
print_error "Working directory is not clean. Please commit or stash your changes."
55+
exit 1
56+
fi
57+
58+
# Validate package.json version matches
59+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
60+
if [ "$PACKAGE_VERSION" != "$version" ]; then
61+
print_error "Package.json version ($PACKAGE_VERSION) doesn't match requested tag version ($version)"
62+
print_info "Make sure the version bump PR has been merged to main"
63+
exit 1
64+
fi
65+
66+
# Check if tag already exists
67+
if git tag -l "v$version" | grep -q "v$version"; then
68+
print_error "Tag v$version already exists"
69+
exit 1
70+
fi
71+
72+
print_step "Creating and pushing tag v$version..."
73+
git tag "v$version"
74+
git push origin "v$version"
75+
76+
print_info "✅ Tag v$version created and pushed successfully!"
77+
print_info "🚀 GitHub Actions will now build and package the release"
78+
print_info "📦 Check the Actions tab for build progress: https://github.com/stepzen-dev/vscode-stepzen/actions"
79+
80+
return 0
81+
}
82+
83+
# Handle --tag flag for post-merge tag creation
84+
if [ "$1" = "--tag" ]; then
85+
if [ $# -ne 2 ]; then
86+
print_error "Usage: $0 --tag <version>"
87+
print_info "Example: $0 --tag 0.1.3"
88+
exit 1
89+
fi
90+
create_and_push_tag "$2"
91+
exit 0
92+
fi
93+
3194
# Check if we're in a git repository
3295
if ! git rev-parse --git-dir > /dev/null 2>&1; then
3396
print_error "Not in a git repository"
@@ -44,7 +107,7 @@ fi
44107
CURRENT_BRANCH=$(git branch --show-current)
45108
if [ "$CURRENT_BRANCH" = "main" ]; then
46109
print_warning "You're on the main branch. For repositories with branch protection:"
47-
print_warning "1. Create a release branch: git checkout -b release/v$NEW_VERSION"
110+
print_warning "1. Create a release branch: git checkout -b release/v\$NEW_VERSION"
48111
print_warning "2. Run this script again from the release branch"
49112
print_warning "3. Push the branch and create a PR"
50113
echo ""
@@ -80,25 +143,25 @@ if git tag -l "v$NEW_VERSION" | grep -q "v$NEW_VERSION"; then
80143
exit 1
81144
fi
82145

83-
print_info "Updating version to $NEW_VERSION..."
146+
print_step "Updating version to $NEW_VERSION..."
84147

85148
# Update package.json version
86149
npm version $NEW_VERSION --no-git-tag-version
87150

88151
# Run tests and linting (build will happen in CI)
89-
print_info "Running tests and linting..."
152+
print_step "Running tests and linting..."
90153
npm run ci:lint
91154

92155
# Commit the version change
93156
git add package.json package-lock.json
94157
git commit -m "chore(release): bump version to $NEW_VERSION"
95158

96-
print_info "Version bump committed successfully!"
159+
print_info "Version bump committed successfully!"
97160

98161
# Provide next steps based on current branch
99162
if [ "$CURRENT_BRANCH" = "main" ]; then
100163
# Direct to main workflow (not recommended with branch protection)
101-
print_info "Creating tag v$NEW_VERSION..."
164+
print_step "Creating tag v$NEW_VERSION..."
102165
git tag "v$NEW_VERSION"
103166

104167
print_warning "Ready to push. Run the following commands to complete the release:"
@@ -108,19 +171,18 @@ if [ "$CURRENT_BRANCH" = "main" ]; then
108171
echo ""
109172
else
110173
# Branch-based workflow (recommended)
111-
print_warning "Next steps for release branch workflow:"
174+
print_info "🎯 Next steps for release branch workflow:"
112175
echo ""
113176
echo " 1. Push the release branch:"
114-
echo " git push origin $CURRENT_BRANCH"
177+
echo " ${BLUE}git push origin $CURRENT_BRANCH${NC}"
115178
echo ""
116179
echo " 2. Create a Pull Request to merge into main"
117180
echo ""
118181
echo " 3. After PR is merged, create and push the tag:"
119-
echo " git checkout main"
120-
echo " git pull origin main"
121-
echo " git tag v$NEW_VERSION"
122-
echo " git push origin v$NEW_VERSION"
182+
echo " ${BLUE}git checkout main && git pull origin main${NC}"
183+
echo " ${BLUE}$0 --tag $NEW_VERSION${NC}"
123184
echo ""
185+
echo " ${GREEN}💡 Pro tip: The --tag flag automates step 3 for you!${NC}"
124186
fi
125187

126-
print_info "The GitHub Actions workflow will automatically build and package the extension when the tag is pushed."
188+
print_info "🚀 The GitHub Actions workflow will automatically build and package the extension when the tag is pushed."

0 commit comments

Comments
 (0)