1
1
#! /bin/sh
2
2
3
+ # Check if we're running in patch mode
4
+ if [ " $1 " = " patch" ]; then
5
+ # Get the current version from package.json
6
+ current_version=$( jq -r ' .version' package.json)
7
+ # Increment the patch version
8
+ version=$( echo $current_version | awk -F. -v OFS=. ' {$NF += 1; print}' )
9
+ echo " Creating patch release: $current_version -> $version "
10
+ elif [ " $1 " = " minor" ]; then
11
+ # Get the current version from package.json
12
+ current_version=$( jq -r ' .version' package.json)
13
+ # Increment the minor version
14
+ version=$( echo $current_version | awk -F. -v OFS=. ' {$2 += 1; $NF = 0; print}' )
15
+ echo " Creating minor release: $current_version -> $version "
3
16
# ensure that we have at least one argument conforming to semver
4
- if [ $# -ne 1 ] || ! echo $1 | grep -qE " ^[0-9]+\.[0-9]+\.[0-9]+$" ; then
5
- echo " Usage: $0 <version>"
17
+ elif [ $# -ne 1 ] || ! echo $1 | grep -qE " ^[0-9]+\.[0-9]+\.[0-9]+$" ; then
18
+ echo " Usage: $0 <version> or $0 patch or $0 minor "
6
19
exit 1
20
+ else
21
+ version=$1
7
22
fi
8
23
9
24
# ensure we are on the master branch otherwise exit
@@ -27,25 +42,6 @@ if [ -n "$(git ls-files --others --exclude-standard)" ]; then
27
42
exit 1
28
43
fi
29
44
30
- # if the first argument is not a valid semver, exit
31
- if ! echo $1 | grep -qE " ^[0-9]+\.[0-9]+\.[0-9]+$" ; then
32
- echo " Invalid semver, exiting"
33
- exit 1
34
- fi
35
-
36
- # get the current version from package.json
37
- current_version=$( jq -r ' .version' package.json)
38
-
39
- # take the version from teh virst argument unless it's "patch" or "minor"
40
- # don't use the semver tool because it's not installed on the CI
41
- if [ " $2 " = " patch" ]; then
42
- version=$( echo $current_version | awk -F. -v OFS=. ' {$NF += 1; print}' )
43
- elif [ " $2 " = " minor" ]; then
44
- version=$( echo $current_version | awk -F. -v OFS=. ' {$2 += 1; $NF = 0; print}' )
45
- else
46
- version=$1
47
- fi
48
-
49
45
# update the version in package.json
50
46
sed -i ' ' -e " s/\" version\" : \" .*\" /\" version\" : \" $version \" /" package.json
51
47
@@ -57,7 +53,7 @@ cargo build
57
53
git add Cargo.toml package.json Cargo.lock
58
54
git commit -m " :rocket: - Release v$version "
59
55
60
- # tag current commit with the first argument
56
+ # tag current commit with the version
61
57
git tag -a v$version -m " :rocket: - Release v$version "
62
58
63
59
# push the changes
0 commit comments