1+ #! /bin/bash
2+ # Check if an argument is provided
3+ if [ -z " $1 " ]; then
4+ echo " Error: VERSION argument is required."
5+ echo " Usage: $0 <VERSION>"
6+ exit 1
7+ fi
8+
9+ # Assign the argument to the VERSION variable
10+ VERSION=$1
11+
12+ echo " VERSION is set to: $VERSION "
13+
14+ # Check that VERSION matches the pattern x.x.x where x is a non-negative integer (allows 0)
15+ if [[ ! " $VERSION " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
16+ echo " Error: VERSION must be in the format x.x.x where x is a non-negative integer (e.g., 0.1.2)"
17+ exit 1
18+ fi
19+
20+ # List of package.json paths
21+ FILES=(
22+ " ./package.json"
23+ )
24+
25+ # Update version in each package.json
26+ for FILE in " ${FILES[@]} " ; do
27+ if [ -f " $FILE " ]; then
28+ jq --arg version " $VERSION " ' .version = $version' " $FILE " > temp.json && mv temp.json " $FILE "
29+ echo " Updated $FILE to version $VERSION "
30+ else
31+ echo " File not found: $FILE "
32+ fi
33+ done
34+
35+ # Remove non-hidden contents while preserving dotfiles (e.g. .gitignore)
36+ for DIR in " dist" " docs/REST" " docs/source" ; do
37+ if [ -d " $DIR " ]; then
38+ find " $DIR " -mindepth 1 -maxdepth 1 ! -name " .*" -exec rm -rf {} +
39+ echo " Cleaned non-hidden contents in $DIR "
40+ fi
41+ done
42+
43+ npm install
44+
45+ git commit -am " Release $VERSION "
46+ git tag " v$VERSION "
47+
48+ echo " ✅ All went well!"
49+ echo " Step 1: Push to GitHub with:"
50+ echo " "
51+ echo " git push origin main && git push origin v$VERSION "
52+ echo " "
53+ echo " Step 2: Publish pacakge to npm with:"
54+ echo " npm publish"
55+ echo " "
56+ echo " Step 3: Create a new release on GitHub with:"
57+ echo " https://github.com/webgme/webgme-engine/releases/new?tag=v$VERSION "
0 commit comments