generated from RedPillAnalytics/docker-cloudbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·70 lines (55 loc) · 1.5 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
69
70
#!/usr/bin/env bash
# get file inputs
repo=$1
branch=$2
stepvars="stepvars"
tagfile="${stepvars}/tag"
versionfile="${stepvars}/version"
minorfile="${stepvars}/minor"
default=0.1.0
# Create stepvars directory if it doesn't exist
mkdir -p stepvars
# properties files
properties="gradle.properties"
# create the gradle.properties file if it isn't there
touch $properties
# write githubToken to the properties file
javaproperties set -o props.temp $properties githubToken $GITHUB_TOKEN
mv props.temp $properties
# grab the stable and alpha versions from GitHub
alpha=`lastversion --pre $1 2> /dev/null`
stable=`lastversion $1 2> /dev/null`
if [[ -z $alpha ]]
then
alpha=$default
fi
# just in case it exists already
#rm -f .semver.yaml
# If there is no alpha version, then bump
if [[ $alpha == $stable ]]
then
semver init --force --release $stable
semver up release > /dev/null
# If there is an alpha version, use that
else
semver init --force --release $alpha
fi
# get the modified version
tag=`semver get release`
# neet to add pre-release marker to non-main branches
if [[ $2 != "master" && $2 != "main" && -f settings.gradle ]]
then
tag=$tag-SNAPSHOT
fi
# write to a file for access across steps
echo $tag > $tagfile
# get non-tag version
version="${tag:1}"
# write to a file for access across steps
echo $version > $versionfile
minor="${version%"."*}.0"
echo $minor > $minorfile
# update the version property
javaproperties set -o props.temp $properties version $version
mv props.temp $properties
echo $version