|
1 | | -#!/bin/bash |
2 | | - |
3 | | -set -e |
4 | | - |
5 | | -# Colors for output |
6 | | -RED='\033[0;31m' |
7 | | -GREEN='\033[0;32m' |
8 | | -YELLOW='\033[1;33m' |
9 | | -BLUE='\033[0;34m' |
10 | | -NC='\033[0m' # No Color |
11 | | - |
12 | | -# Version type (patch, minor, major) |
13 | | -VERSION_TYPE=$1 |
14 | | - |
15 | | -if [ -z "$VERSION_TYPE" ]; then |
16 | | - echo -e "${RED}❌ Error: Version type required (patch, minor, or major)${NC}" |
17 | | - echo "Usage: bash scripts/release.sh [patch|minor|major]" |
18 | | - exit 1 |
19 | | -fi |
20 | | - |
21 | | -if [[ ! "$VERSION_TYPE" =~ ^(patch|minor|major)$ ]]; then |
22 | | - echo -e "${RED}❌ Error: Invalid version type '$VERSION_TYPE'${NC}" |
23 | | - echo "Valid types: patch, minor, major" |
24 | | - exit 1 |
25 | | -fi |
26 | | - |
27 | | -echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
28 | | -echo -e "${BLUE}🚀 Starting Release Process - $VERSION_TYPE version bump${NC}" |
29 | | -echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
30 | | - |
31 | | -# Check if git working directory is clean |
32 | | -if [ -n "$(git status --porcelain)" ]; then |
33 | | - echo -e "${RED}❌ Error: Working directory is not clean${NC}" |
34 | | - echo "Please commit or stash your changes before releasing" |
35 | | - git status --short |
36 | | - exit 1 |
37 | | -fi |
38 | | - |
39 | | -# Check if on main branch (optional, comment out if not needed) |
40 | | -CURRENT_BRANCH=$(git branch --show-current) |
41 | | -if [ "$CURRENT_BRANCH" != "main" ] && [ "$CURRENT_BRANCH" != "master" ]; then |
42 | | - echo -e "${YELLOW}⚠️ Warning: Not on main/master branch (current: $CURRENT_BRANCH)${NC}" |
43 | | - read -p "Continue anyway? (y/N) " -n 1 -r |
44 | | - echo |
45 | | - if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
46 | | - exit 1 |
47 | | - fi |
48 | | -fi |
49 | | - |
50 | | -# Get current version |
51 | | -CURRENT_VERSION=$(node -p "require('./package.json').version") |
52 | | -echo -e "${BLUE}📦 Current version: ${YELLOW}$CURRENT_VERSION${NC}" |
53 | | - |
54 | | -# Run pre-release checks |
55 | | -echo -e "\n${BLUE}🔍 Running pre-release checks...${NC}" |
56 | | - |
57 | | -echo -e "${BLUE} 1/5 Running linter...${NC}" |
58 | | -pnpm run lint || { |
59 | | - echo -e "${RED}❌ Linting failed${NC}" |
60 | | - exit 1 |
61 | | -} |
62 | | - |
63 | | -echo -e "${BLUE} 2/5 Running type check...${NC}" |
64 | | -pnpm run typecheck || { |
65 | | - echo -e "${RED}❌ Type checking failed${NC}" |
66 | | - exit 1 |
67 | | -} |
68 | | - |
69 | | -echo -e "${BLUE} 3/5 Running tests...${NC}" |
70 | | -pnpm run test:run || { |
71 | | - echo -e "${RED}❌ Tests failed${NC}" |
72 | | - exit 1 |
73 | | -} |
74 | | - |
75 | | -echo -e "${BLUE} 4/5 Building package...${NC}" |
76 | | -pnpm run build || { |
77 | | - echo -e "${RED}❌ Build failed${NC}" |
78 | | - exit 1 |
79 | | -} |
80 | | - |
81 | | -echo -e "${BLUE} 5/5 Building documentation...${NC}" |
82 | | -pnpm run docs:build || { |
83 | | - echo -e "${RED}❌ Documentation build failed${NC}" |
84 | | - exit 1 |
85 | | -} |
86 | | - |
87 | | -echo -e "${GREEN}✅ All pre-release checks passed!${NC}" |
88 | | - |
89 | | -# Bump version (this will also run 'version' script which updates changelog) |
90 | | -echo -e "\n${BLUE}📝 Bumping version ($VERSION_TYPE)...${NC}" |
91 | | -pnpm version $VERSION_TYPE --no-git-tag-version |
92 | | - |
93 | | -# Get new version |
94 | | -NEW_VERSION=$(node -p "require('./package.json').version") |
95 | | -echo -e "${GREEN}✅ Version bumped: ${YELLOW}$CURRENT_VERSION → $NEW_VERSION${NC}" |
96 | | - |
97 | | -# Generate changelog |
98 | | -echo -e "\n${BLUE}📝 Generating changelog...${NC}" |
99 | | -pnpm run changelog || { |
100 | | - echo -e "${YELLOW}⚠️ Changelog generation failed, continuing...${NC}" |
101 | | -} |
102 | | - |
103 | | -# Commit changes |
104 | | -echo -e "\n${BLUE}💾 Committing changes...${NC}" |
105 | | -git add package.json CHANGELOG.md docs/.vitepress/dist |
106 | | -git commit -m "chore(release): v$NEW_VERSION" || { |
107 | | - echo -e "${YELLOW}⚠️ Nothing to commit${NC}" |
108 | | -} |
109 | | - |
110 | | -# Create git tag |
111 | | -echo -e "\n${BLUE}🏷️ Creating git tag v$NEW_VERSION...${NC}" |
112 | | -git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION" |
113 | | - |
114 | | -# Push to remote |
115 | | -echo -e "\n${BLUE}📤 Pushing to remote...${NC}" |
116 | | -git push origin $CURRENT_BRANCH |
117 | | -git push origin "v$NEW_VERSION" |
118 | | - |
119 | | -echo -e "${GREEN}✅ Git tag created and pushed${NC}" |
120 | | - |
121 | | -# Publish to npm |
122 | | -echo -e "\n${BLUE}📦 Publishing to npm...${NC}" |
123 | | -echo -e "${YELLOW}⚠️ This will publish version $NEW_VERSION to npm${NC}" |
124 | | -read -p "Continue with npm publish? (y/N) " -n 1 -r |
125 | | -echo |
126 | | - |
127 | | -if [[ $REPLY =~ ^[Yy]$ ]]; then |
128 | | - pnpm publish --access public --no-git-checks || { |
129 | | - echo -e "${RED}❌ npm publish failed${NC}" |
130 | | - echo -e "${YELLOW}Don't worry, the version bump and git tag are already pushed.${NC}" |
131 | | - echo -e "${YELLOW}You can manually publish later with: pnpm publish --access public${NC}" |
132 | | - exit 1 |
133 | | - } |
134 | | - |
135 | | - echo -e "\n${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
136 | | - echo -e "${GREEN}🎉 Release v$NEW_VERSION completed successfully!${NC}" |
137 | | - echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
138 | | - echo -e "${GREEN}✅ Package published to npm${NC}" |
139 | | - echo -e "${GREEN}✅ Git tag pushed to remote${NC}" |
140 | | - echo -e "${GREEN}✅ Changelog updated${NC}" |
141 | | - echo -e "" |
142 | | - echo -e "${BLUE}📦 npm: ${YELLOW}https://www.npmjs.com/package/@ndriadev/vite-plugin-universal-api${NC}" |
143 | | - echo -e "${BLUE}🏷️ Tag: ${YELLOW}https://github.com/nDriaDev/vite-plugin-universal-api/releases/tag/v$NEW_VERSION${NC}" |
144 | | -else |
145 | | - echo -e "\n${YELLOW}⚠️ Skipped npm publish${NC}" |
146 | | - echo -e "${BLUE}Version bump and git tag have been pushed to remote.${NC}" |
147 | | - echo -e "${BLUE}To publish manually later, run: ${YELLOW}pnpm publish --access public${NC}" |
148 | | -fi |
149 | | - |
150 | | -echo "" |
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +# Colors for output |
| 6 | +RED='\033[0;31m' |
| 7 | +GREEN='\033[0;32m' |
| 8 | +YELLOW='\033[1;33m' |
| 9 | +BLUE='\033[0;34m' |
| 10 | +NC='\033[0m' # No Color |
| 11 | + |
| 12 | +# Version type (patch, minor, major) |
| 13 | +VERSION_TYPE=$1 |
| 14 | + |
| 15 | +if [ -z "$VERSION_TYPE" ]; then |
| 16 | + echo -e "${RED}❌ Error: Version type required (patch, minor, or major)${NC}" |
| 17 | + echo "Usage: bash scripts/release.sh [patch|minor|major]" |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | + |
| 21 | +if [[ ! "$VERSION_TYPE" =~ ^(patch|minor|major)$ ]]; then |
| 22 | + echo -e "${RED}❌ Error: Invalid version type '$VERSION_TYPE'${NC}" |
| 23 | + echo "Valid types: patch, minor, major" |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
| 28 | +echo -e "${BLUE}🚀 Starting Release Process - $VERSION_TYPE version bump${NC}" |
| 29 | +echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
| 30 | + |
| 31 | +# Check if git working directory is clean |
| 32 | +if [ -n "$(git status --porcelain)" ]; then |
| 33 | + echo -e "${RED}❌ Error: Working directory is not clean${NC}" |
| 34 | + echo "Please commit or stash your changes before releasing" |
| 35 | + git status --short |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +# Check if on main branch (optional, comment out if not needed) |
| 40 | +CURRENT_BRANCH=$(git branch --show-current) |
| 41 | +if [ "$CURRENT_BRANCH" != "main" ] && [ "$CURRENT_BRANCH" != "master" ]; then |
| 42 | + echo -e "${YELLOW}⚠️ Warning: Not on main/master branch (current: $CURRENT_BRANCH)${NC}" |
| 43 | + read -p "Continue anyway? (y/N) " -n 1 -r |
| 44 | + echo |
| 45 | + if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +fi |
| 49 | + |
| 50 | +# Get current version |
| 51 | +CURRENT_VERSION=$(node -p "require('./package.json').version") |
| 52 | +echo -e "${BLUE}📦 Current version: ${YELLOW}$CURRENT_VERSION${NC}" |
| 53 | + |
| 54 | +# Run pre-release checks |
| 55 | +echo -e "\n${BLUE}🔍 Running pre-release checks...${NC}" |
| 56 | + |
| 57 | +echo -e "${BLUE} 1/4 Running linter...${NC}" |
| 58 | +pnpm run lint || { |
| 59 | + echo -e "${RED}❌ Linting failed${NC}" |
| 60 | + exit 1 |
| 61 | +} |
| 62 | + |
| 63 | +echo -e "${BLUE} 2/4 Running type check...${NC}" |
| 64 | +pnpm run typecheck || { |
| 65 | + echo -e "${RED}❌ Type checking failed${NC}" |
| 66 | + exit 1 |
| 67 | +} |
| 68 | + |
| 69 | +echo -e "${BLUE} 3/4 Running tests...${NC}" |
| 70 | +pnpm run test:run || { |
| 71 | + echo -e "${RED}❌ Tests failed${NC}" |
| 72 | + exit 1 |
| 73 | +} |
| 74 | + |
| 75 | +echo -e "${BLUE} 4/4 Building package...${NC}" |
| 76 | +pnpm run build || { |
| 77 | + echo -e "${RED}❌ Build failed${NC}" |
| 78 | + exit 1 |
| 79 | +} |
| 80 | + |
| 81 | +# DOCS generated from github action |
| 82 | +# echo -e "${BLUE} 5/5 Building documentation...${NC}" |
| 83 | +# pnpm run docs:build || { |
| 84 | +# echo -e "${RED}❌ Documentation build failed${NC}" |
| 85 | +# exit 1 |
| 86 | +# } |
| 87 | + |
| 88 | +echo -e "${GREEN}✅ All pre-release checks passed!${NC}" |
| 89 | + |
| 90 | +# Bump version (this will also run 'version' script which updates changelog) |
| 91 | +echo -e "\n${BLUE}📝 Bumping version ($VERSION_TYPE)...${NC}" |
| 92 | +pnpm version $VERSION_TYPE --no-git-tag-version |
| 93 | + |
| 94 | +# Get new version |
| 95 | +NEW_VERSION=$(node -p "require('./package.json').version") |
| 96 | +echo -e "${GREEN}✅ Version bumped: ${YELLOW}$CURRENT_VERSION → $NEW_VERSION${NC}" |
| 97 | + |
| 98 | +# Generate changelog |
| 99 | +echo -e "\n${BLUE}📝 Generating changelog...${NC}" |
| 100 | +pnpm run changelog || { |
| 101 | + echo -e "${YELLOW}⚠️ Changelog generation failed, continuing...${NC}" |
| 102 | +} |
| 103 | + |
| 104 | +# Commit changes |
| 105 | +echo -e "\n${BLUE}💾 Committing changes...${NC}" |
| 106 | +git add package.json CHANGELOG.md |
| 107 | +git commit -m "chore(release): v$NEW_VERSION" || { |
| 108 | + echo -e "${YELLOW}⚠️ Nothing to commit${NC}" |
| 109 | +} |
| 110 | + |
| 111 | +# Create git tag |
| 112 | +echo -e "\n${BLUE}🏷️ Creating git tag v$NEW_VERSION...${NC}" |
| 113 | +git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION" |
| 114 | + |
| 115 | +# Push to remote |
| 116 | +echo -e "\n${BLUE}📤 Pushing to remote...${NC}" |
| 117 | +git push origin $CURRENT_BRANCH |
| 118 | +git push origin "v$NEW_VERSION" |
| 119 | + |
| 120 | +echo -e "${GREEN}✅ Git tag created and pushed${NC}" |
| 121 | + |
| 122 | +# Publish to npm |
| 123 | +echo -e "\n${BLUE}📦 Publishing to npm...${NC}" |
| 124 | +echo -e "${YELLOW}⚠️ This will publish version $NEW_VERSION to npm${NC}" |
| 125 | +read -p "Continue with npm publish? (y/N) " -n 1 -r |
| 126 | +echo |
| 127 | + |
| 128 | +if [[ $REPLY =~ ^[Yy]$ ]]; then |
| 129 | + pnpm publish --access public --no-git-checks || { |
| 130 | + echo -e "${RED}❌ npm publish failed${NC}" |
| 131 | + echo -e "${YELLOW}Don't worry, the version bump and git tag are already pushed.${NC}" |
| 132 | + echo -e "${YELLOW}You can manually publish later with: pnpm publish --access public${NC}" |
| 133 | + exit 1 |
| 134 | + } |
| 135 | + |
| 136 | + echo -e "\n${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
| 137 | + echo -e "${GREEN}🎉 Release v$NEW_VERSION completed successfully!${NC}" |
| 138 | + echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" |
| 139 | + echo -e "${GREEN}✅ Package published to npm${NC}" |
| 140 | + echo -e "${GREEN}✅ Git tag pushed to remote${NC}" |
| 141 | + echo -e "${GREEN}✅ Changelog updated${NC}" |
| 142 | + echo -e "" |
| 143 | + echo -e "${BLUE}📦 npm: ${YELLOW}https://www.npmjs.com/package/@ndriadev/vite-plugin-universal-api${NC}" |
| 144 | + echo -e "${BLUE}🏷️ Tag: ${YELLOW}https://github.com/nDriaDev/vite-plugin-universal-api/releases/tag/v$NEW_VERSION${NC}" |
| 145 | +else |
| 146 | + echo -e "\n${YELLOW}⚠️ Skipped npm publish${NC}" |
| 147 | + echo -e "${BLUE}Version bump and git tag have been pushed to remote.${NC}" |
| 148 | + echo -e "${BLUE}To publish manually later, run: ${YELLOW}pnpm publish --access public${NC}" |
| 149 | +fi |
| 150 | + |
| 151 | +echo "" |
0 commit comments