forked from graphql-java-kickstart/graphql-spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github-build.sh
53 lines (43 loc) · 1.39 KB
/
github-build.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
#!/bin/bash
set -ev
getVersion() {
./gradlew properties -q | grep -E "^version" | awk '{print $2}' | tr -d '[:space:]'
}
removeSnapshots() {
sed -i 's/-SNAPSHOT//' gradle.properties
}
commitRelease() {
local APP_VERSION=$(getVersion)
git commit -a -m "Update version for release"
git tag -a "v${APP_VERSION}" -m "Tag release version"
}
bumpVersion() {
echo "Bump version number"
local APP_VERSION=$(getVersion | xargs)
local SEMANTIC_REGEX='^([0-9]+)\.([0-9]+)(\.([0-9]+))?$'
if [[ ${APP_VERSION} =~ ${SEMANTIC_REGEX} ]]; then
if [[ ${BASH_REMATCH[4]} ]]; then
nextVersion=$((BASH_REMATCH[4] + 1))
nextVersion="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${nextVersion}-SNAPSHOT"
else
nextVersion=$((BASH_REMATCH[2] + 1))
nextVersion="${BASH_REMATCH[1]}.${nextVersion}-SNAPSHOT"
fi
echo "Next version: ${nextVersion}"
sed -i -E "s/^version(\s)?=.*/version=${nextVersion}/" gradle.properties
else
echo "No semantic version and therefore cannot publish to maven repository: '${APP_VERSION}'"
fi
}
commitNextVersion() {
git commit -a -m "Update version for release"
}
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
echo "Deploying release to Bintray"
removeSnapshots
./gradlew clean assemble && ./gradlew bintrayUpload -x check --info
commitRelease
bumpVersion
commitNextVersion
git push --follow-tags