-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·68 lines (56 loc) · 1.16 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
function incrementVersion {
cmpt=0
IFS='.'
read -ra ADDR <<< "$1"
for i in "${ADDR[@]}"; do
if [ $cmpt == 0 ];
then
major="$i"
elif [ $cmpt == 1 ];
then
minor="$i"
else
patch="$i"
fi
cmpt=$((cmpt+1))
done
bump=${DESIRED_BUMP:-minor}
if [ $bump == 'major' ];
then
major=$((major+1))
minor=0
patch=0
elif [ $bump == 'patch' ];
then
patch=$((patch+1))
else
minor=$((minor+1))
patch=0
fi
tag=$major"."$minor"."$patch
IFS=''
}
cd ${GITHUB_WORKSPACE}
git fetch --tags
# get latest tag
gitTag=$(git describe --tags `git rev-list --tags --max-count=1`)
if [ -z "$gitTag" ]
then
# no tag, start with 0.0.0
tag=0.0.0
else
# remove the v in front of the existing tag
tag=${gitTag#"v"}
fi
incrementVersion $tag
# get the npm version
npmversion=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
if [ $tag != $npmversion ];
then
# update npm version
tag=$(npm version ${tag} --no-git-tag-version)
echo "::set-output name=new_npm_version::$tag"
else
echo "::set-output name=new_npm_version::$npmversion"
fi