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
1014set -e
1115
1216# Colors for output
1317RED=' \033[0;31m'
1418GREEN=' \033[0;32m'
1519YELLOW=' \033[1;33m'
20+ BLUE=' \033[0;34m'
1621NC=' \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
3295if ! git rev-parse --git-dir > /dev/null 2>&1 ; then
3396 print_error " Not in a git repository"
44107CURRENT_BRANCH=$( git branch --show-current)
45108if [ " $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
81144fi
82145
83- print_info " Updating version to $NEW_VERSION ..."
146+ print_step " Updating version to $NEW_VERSION ..."
84147
85148# Update package.json version
86149npm 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..."
90153npm run ci:lint
91154
92155# Commit the version change
93156git add package.json package-lock.json
94157git 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
99162if [ " $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 " "
109172else
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} "
124186fi
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