Skip to content

Commit cedddf2

Browse files
committed
create release script
1 parent bf3ebfa commit cedddf2

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

release.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Get current version from package.json
6+
CURRENT_VERSION=$(jq -r '.version' package.json)
7+
8+
echo "Current version: $CURRENT_VERSION"
9+
10+
# Parse version components
11+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
12+
13+
# Calculate next patch version
14+
NEXT_PATCH="$MAJOR.$MINOR.$((PATCH + 1))"
15+
16+
# Prompt for new version
17+
echo "Enter new version (or press Enter for $NEXT_PATCH):"
18+
read -r INPUT
19+
20+
# Determine new version
21+
if [[ -z "$INPUT" ]]; then
22+
NEW_VERSION="$NEXT_PATCH"
23+
elif [[ "$INPUT" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
24+
NEW_VERSION="$INPUT"
25+
else
26+
echo "Invalid version: $INPUT"
27+
echo "Please enter a semver like X.Y.Z"
28+
exit 1
29+
fi
30+
31+
echo "New version: $NEW_VERSION"
32+
33+
# Update package.json
34+
jq --arg v "$NEW_VERSION" '.version = $v' package.json > package.json.tmp && mv package.json.tmp package.json
35+
36+
# Update manifest.json
37+
jq --arg v "$NEW_VERSION" '.version = $v' manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json
38+
39+
echo "Updated package.json and manifest.json to version $NEW_VERSION"
40+
41+
# Git operations
42+
git add package.json manifest.json
43+
git commit -m "chore: bump version to $NEW_VERSION"
44+
git tag "v$NEW_VERSION"
45+
46+
echo "Created commit and tag v$NEW_VERSION"
47+
48+
# Push commit and tag
49+
git push && git push origin "v$NEW_VERSION"
50+
51+
echo "Pushed commit and tag to remote"
52+
echo "Done! Version bumped to $NEW_VERSION"

0 commit comments

Comments
 (0)