Skip to content

Commit fc43c1b

Browse files
committed
Improve release script with version and changelog checks
Add logic to detect if CHANGELOG and version are already updated, offer to reuse current version, and handle existing tags. Streamline commit and tagging process for repeated releases. Remove VSCode extension notes from CHANGELOG.
1 parent 5f33d47 commit fc43c1b

File tree

2 files changed

+99
-64
lines changed

2 files changed

+99
-64
lines changed

nodejs-compressor/CHANGELOG.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Responsive grid layout for format cards
2424
- Key findings section explaining token efficiency
2525

26-
- **VSCode Extension - Language Server**
27-
- ASON language server with LSP features
28-
- Real-time syntax validation and error detection
29-
- Autocomplete for dictionary references (`#0`, `#1`, etc.)
30-
- Autocomplete for object aliases (`&obj0`, `&obj1`, etc.)
31-
- Go to definition for references
32-
- Hover tooltips showing full values
33-
- Smart filtering - typing `#1` filters to `#1`, `#10`, `#11`, etc.
34-
- Context caching for performance
35-
- Proper `textEdit` range replacement (no duplicate insertions)
36-
- Support for `$def:` and `$data:` sections
37-
- Dictionary value detection in both sections
38-
- Fix: Autocomplete now works immediately on file open
39-
40-
- **VSCode Extension - Syntax Highlighting**
41-
- TextMate grammar for `.ason` files
42-
- Syntax highlighting for keys, values, references, sections
43-
- File icon for `.ason` files in explorer
44-
- Professional gradient icon design (teal with `#` symbol and braces)
45-
- Icon theme integration
46-
- Simplified syntax patterns for better color consistency
47-
4826
### Changed
4927
- **CI/CD - Automated Publishing with Provenance**
5028
- Updated `/.github/workflows/npm-publish.yml` with npm provenance support

nodejs-compressor/scripts/release.sh

Lines changed: 99 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,81 @@ echo ""
2121
CURRENT_VERSION=$(node -p "require('../package.json').version")
2222
echo -e "Current version: ${YELLOW}v${CURRENT_VERSION}${NC}"
2323

24-
# Select version bump type
25-
echo ""
26-
echo -e "${GREEN}Select version bump:${NC}"
27-
echo " 1) patch - Bug fixes (${CURRENT_VERSION}$(npm version patch --no-git-tag-version | tail -1 && npm version ${CURRENT_VERSION} --no-git-tag-version >/dev/null 2>&1))"
28-
echo " 2) minor - New features (${CURRENT_VERSION}$(npm version minor --no-git-tag-version | tail -1 && npm version ${CURRENT_VERSION} --no-git-tag-version >/dev/null 2>&1))"
29-
echo " 3) major - Breaking changes (${CURRENT_VERSION}$(npm version major --no-git-tag-version | tail -1 && npm version ${CURRENT_VERSION} --no-git-tag-version >/dev/null 2>&1))"
30-
echo ""
31-
read -p "Enter choice (1-3): " BUMP_CHOICE
32-
33-
case $BUMP_CHOICE in
34-
1) BUMP_TYPE="patch" ;;
35-
2) BUMP_TYPE="minor" ;;
36-
3) BUMP_TYPE="major" ;;
37-
*)
38-
echo -e "${RED}Invalid choice${NC}"
39-
exit 1
40-
;;
41-
esac
42-
43-
# Bump version
44-
echo ""
45-
echo -e "${BLUE}Bumping version...${NC}"
46-
NEW_VERSION=$(npm version $BUMP_TYPE --no-git-tag-version)
47-
NEW_VERSION=${NEW_VERSION#v}
24+
# Check if CHANGELOG already has this version
25+
if grep -q "## \[${CURRENT_VERSION}\]" ../CHANGELOG.md 2>/dev/null; then
26+
echo -e "${YELLOW}⚠ CHANGELOG already updated for v${CURRENT_VERSION}${NC}"
27+
echo ""
28+
read -p "Use current version v${CURRENT_VERSION} for release? (Y/n): " -n 1 -r
29+
echo
30+
if [[ $REPLY =~ ^[Nn]$ ]]; then
31+
USE_CURRENT=false
32+
else
33+
USE_CURRENT=true
34+
fi
35+
else
36+
USE_CURRENT=false
37+
fi
4838

49-
echo -e "New version: ${GREEN}v${NEW_VERSION}${NC}"
50-
echo ""
39+
if [ "$USE_CURRENT" = true ]; then
40+
NEW_VERSION=$CURRENT_VERSION
41+
echo -e "Using current version: ${GREEN}v${NEW_VERSION}${NC}"
42+
echo ""
43+
else
44+
# Select version bump type
45+
echo ""
46+
echo -e "${GREEN}Select version bump:${NC}"
47+
echo " 1) patch - Bug fixes (${CURRENT_VERSION} → v$(node -p "require('semver').inc('${CURRENT_VERSION}', 'patch')"))"
48+
echo " 2) minor - New features (${CURRENT_VERSION} → v$(node -p "require('semver').inc('${CURRENT_VERSION}', 'minor')"))"
49+
echo " 3) major - Breaking changes (${CURRENT_VERSION} → v$(node -p "require('semver').inc('${CURRENT_VERSION}', 'major')"))"
50+
echo " 4) Use current version v${CURRENT_VERSION}"
51+
echo ""
52+
read -p "Enter choice (1-4): " BUMP_CHOICE
53+
54+
case $BUMP_CHOICE in
55+
1) BUMP_TYPE="patch" ;;
56+
2) BUMP_TYPE="minor" ;;
57+
3) BUMP_TYPE="major" ;;
58+
4)
59+
NEW_VERSION=$CURRENT_VERSION
60+
echo -e "Using current version: ${GREEN}v${NEW_VERSION}${NC}"
61+
echo ""
62+
;;
63+
*)
64+
echo -e "${RED}Invalid choice${NC}"
65+
exit 1
66+
;;
67+
esac
68+
69+
# Bump version if not using current
70+
if [ "$BUMP_CHOICE" != "4" ]; then
71+
echo ""
72+
echo -e "${BLUE}Bumping version...${NC}"
73+
NEW_VERSION=$(npm version $BUMP_TYPE --no-git-tag-version)
74+
NEW_VERSION=${NEW_VERSION#v}
75+
echo -e "New version: ${GREEN}v${NEW_VERSION}${NC}"
76+
echo ""
77+
fi
78+
fi
5179

52-
# Update CHANGELOG
53-
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
54-
echo -e "${YELLOW}IMPORTANT: Update CHANGELOG.md${NC}"
55-
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
56-
echo ""
57-
echo "Change from:"
58-
echo -e " ${RED}## [Unreleased]${NC}"
59-
echo ""
60-
echo "To:"
61-
echo -e " ${GREEN}## [${NEW_VERSION}] - $(date +%Y-%m-%d)${NC}"
62-
echo ""
63-
read -p "Press ENTER when you've updated CHANGELOG.md..."
80+
# Skip CHANGELOG update if already done
81+
if grep -q "## \[${NEW_VERSION}\]" ../CHANGELOG.md 2>/dev/null; then
82+
echo -e "${GREEN}✓ CHANGELOG already updated for v${NEW_VERSION}${NC}"
83+
echo ""
84+
else
85+
# Update CHANGELOG
86+
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
87+
echo -e "${YELLOW}IMPORTANT: Update CHANGELOG.md${NC}"
88+
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
89+
echo ""
90+
echo "Change from:"
91+
echo -e " ${RED}## [Unreleased]${NC}"
92+
echo ""
93+
echo "To:"
94+
echo -e " ${GREEN}## [${NEW_VERSION}] - $(date +%Y-%m-%d)${NC}"
95+
echo ""
96+
read -p "Press ENTER when you've updated CHANGELOG.md..."
97+
echo ""
98+
fi
6499

65100
# Build
66101
echo ""
@@ -79,11 +114,33 @@ npm test || {
79114
fi
80115
}
81116

82-
# Commit and tag
83-
git add package.json CHANGELOG.md package-lock.json 2>/dev/null || true
84-
git commit -m "Release v${NEW_VERSION}"
85-
117+
# Check if tag already exists
86118
TAG_NAME="v${NEW_VERSION}"
119+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
120+
echo -e "${YELLOW}⚠ Tag ${TAG_NAME} already exists${NC}"
121+
read -p "Delete and recreate tag? (y/N): " -n 1 -r
122+
echo
123+
if [[ $REPLY =~ ^[Yy]$ ]]; then
124+
git tag -d "$TAG_NAME"
125+
echo -e "${GREEN}✓ Deleted existing tag${NC}"
126+
else
127+
echo -e "${RED}Aborting. Tag already exists.${NC}"
128+
exit 1
129+
fi
130+
fi
131+
132+
# Add files
133+
git add package.json CHANGELOG.md package-lock.json dist/ 2>/dev/null || true
134+
135+
# Check if there are changes to commit
136+
if git diff --cached --quiet; then
137+
echo -e "${YELLOW}No changes to commit (files already staged or committed)${NC}"
138+
else
139+
git commit -m "chore: release v${NEW_VERSION}"
140+
echo -e "${GREEN}✓ Changes committed${NC}"
141+
fi
142+
143+
# Create tag
87144
git tag -a "$TAG_NAME" -m "Release v${NEW_VERSION}"
88145

89146
echo ""

0 commit comments

Comments
 (0)