1+ #! /bin/bash
2+
3+ # Release script for GitHub Auto-Label Issues & Templates Action
4+ # Usage: ./scripts/release.sh [patch|minor|major]
5+
6+ set -e
7+
8+ # Colors for output
9+ RED=' \033[0;31m'
10+ GREEN=' \033[0;32m'
11+ YELLOW=' \033[1;33m'
12+ BLUE=' \033[0;34m'
13+ NC=' \033[0m' # No Color
14+
15+ # Function to print colored output
16+ print_status () {
17+ echo -e " ${BLUE} [INFO]${NC} $1 "
18+ }
19+
20+ print_success () {
21+ echo -e " ${GREEN} [SUCCESS]${NC} $1 "
22+ }
23+
24+ print_warning () {
25+ echo -e " ${YELLOW} [WARNING]${NC} $1 "
26+ }
27+
28+ print_error () {
29+ echo -e " ${RED} [ERROR]${NC} $1 "
30+ }
31+
32+ # Check if we're in the right directory
33+ if [ ! -f " package.json" ]; then
34+ print_error " package.json not found. Please run this script from the repository root."
35+ exit 1
36+ fi
37+
38+ # Get current version
39+ CURRENT_VERSION=$( node -p " require('./package.json').version" )
40+ print_status " Current version: $CURRENT_VERSION "
41+
42+ # Determine version bump type
43+ BUMP_TYPE=${1:- patch}
44+ if [[ ! " $BUMP_TYPE " =~ ^(patch| minor| major)$ ]]; then
45+ print_error " Invalid bump type. Use: patch, minor, or major"
46+ exit 1
47+ fi
48+
49+ print_status " Bumping version: $BUMP_TYPE "
50+
51+ # Check if there are uncommitted changes
52+ if [ -n " $( git status --porcelain) " ]; then
53+ print_warning " You have uncommitted changes. Please commit or stash them first."
54+ git status --short
55+ exit 1
56+ fi
57+
58+ # Check if we're on the production branch
59+ CURRENT_BRANCH=$( git branch --show-current)
60+ if [ " $CURRENT_BRANCH " != " production" ]; then
61+ print_warning " You're not on the production branch. Current branch: $CURRENT_BRANCH "
62+ read -p " Continue anyway? (y/N): " -n 1 -r
63+ echo
64+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
65+ exit 1
66+ fi
67+ fi
68+
69+ # Bump version
70+ print_status " Bumping version in package.json..."
71+ NEW_VERSION=$( npm version $BUMP_TYPE --no-git-tag-version)
72+ NEW_VERSION=${NEW_VERSION# v} # Remove 'v' prefix
73+
74+ print_success " Version bumped to: $NEW_VERSION "
75+
76+ # Update CHANGELOG.md
77+ print_status " Updating changelog..."
78+ npm run changelog
79+
80+ # Commit changes
81+ print_status " Committing changes..."
82+ git add package.json CHANGELOG.md
83+ git commit -m " chore(release): bump version to $NEW_VERSION "
84+
85+ # Create and push tag
86+ print_status " Creating tag v$NEW_VERSION ..."
87+ git tag -a " v$NEW_VERSION " -m " chore(release): release version $NEW_VERSION "
88+
89+ # Push changes
90+ print_status " Pushing changes and tag..."
91+ git push origin production
92+ git push origin " v$NEW_VERSION "
93+
94+ print_success " Release v$NEW_VERSION created successfully!"
95+ print_status " GitHub Actions will now:"
96+ print_status " 1. Update package.json version to $NEW_VERSION "
97+ print_status " 2. Generate changelog from conventional commits"
98+ print_status " 3. Create GitHub release with changelog"
99+ print_status " 4. Update release notes"
100+
101+ print_status " You can monitor the release at:"
102+ print_status " https://github.com/Devlander-Software/issue-labler/releases/tag/v$NEW_VERSION "
0 commit comments