@@ -12,23 +12,56 @@ if [ $(git rev-parse --abbrev-ref HEAD) != "master" ]; then
12
12
exit 1
13
13
fi
14
14
15
- # update the version in package.json
16
- sed -i ' ' -e " s/\" version\" : \" .*\" /\" version\" : \" $1 \" /" package.json
15
+ # ensure master is up to date
16
+ git pull
17
+
18
+ # ensure that there are no uncommitted changes
19
+ if [ -n " $( git status --porcelain) " ]; then
20
+ echo " There are uncommitted changes, exiting"
21
+ exit 1
22
+ fi
23
+
24
+ # ensure that there are no untracked files
25
+ if [ -n " $( git ls-files --others --exclude-standard) " ]; then
26
+ echo " There are untracked files, exiting"
27
+ exit 1
28
+ fi
17
29
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
+ # update the version in package.json
50
+ sed -i ' ' -e " s/\" version\" : \" .*\" /\" version\" : \" $version \" /" package.json
18
51
19
52
# update the version in cargo.toml
20
- sed -i ' ' -e " s/^version = \" .*\" /version = \" $1 \" /" Cargo.toml
53
+ sed -i ' ' -e " s/^version = \" .*\" /version = \" $version \" /" Cargo.toml
21
54
cargo build
22
55
23
56
# commit the changes with the version
24
57
git add Cargo.toml package.json Cargo.lock
25
- git commit -m " :rocket: - Release v$1 "
58
+ git commit -m " :rocket: - Release v$version "
26
59
27
60
# tag current commit with the first argument
28
- git tag -a v$1 -m " :rocket: - Release v$1 "
61
+ git tag -a v$version -m " :rocket: - Release v$version "
29
62
30
63
# push the changes
31
64
git push origin master
32
65
33
66
# push the tag
34
- git push origin v$1
67
+ git push origin v$version
0 commit comments