-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-gradle.sh
executable file
·64 lines (50 loc) · 1.95 KB
/
build-gradle.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
#!/bin/bash
set -e
export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:--Xmx4096m}"
if [[ $(git rev-parse --is-shallow-repository) == "true" ]]
then
git fetch --unshallow
fi
if [[ -z "$GRADLE_CACHE_USERNAME" || -z "$GRADLE_CACHE_PASSWORD" ]]; then
echo "============================================================"
echo "Set GRADLE_CACHE_USERNAME and GRADLE_CACHE_PASSWORD"
echo "environment variables to take advantage of the build cache!"
echo "============================================================"
fi
if [ -z "$GITHUB_RUN_NUMBER" ]; then
if [[ "$DISABLE_BUILD_SCAN" == "true" ]]; then
./gradlew $GRADLE_PARAMS
else
./gradlew $GRADLE_PARAMS --scan
fi
else
version=""
echo "GITHUB_ACTIONS_TAG ${GITHUB_ACTIONS_TAG}"
if [[ -z "$GITHUB_ACTIONS_PULL_REQUEST" && "$GITHUB_ACTIONS_PULL_REQUEST" != "" ]]; then
echo "GITHUB_ACTIONS_PULL_REQUEST ${GITHUB_ACTIONS_PULL_REQUEST}"
version="PR$GITHUB_ACTIONS_PULL_REQUEST"
elif [[ "$GITHUB_ACTIONS_TAG" =~ ^v[0-9]+\. ]]; then
echo "GITHUB_ACTIONS_TAG ${GITHUB_ACTIONS_TAG}"
version=${GITHUB_ACTIONS_TAG/v/}
else
COMMIT_COUNT=$(git rev-list --count HEAD)
COMMIT_SHA=$(git rev-parse --short=6 HEAD)
version=$(git describe --tags --match "v[0-9]*" --abbrev=6 HEAD || echo v0-$COMMIT_COUNT-g$COMMIT_SHA)
version=${version/v/}
BUILD_NUM=${GITHUB_RUN_NUMBER}
if ! [[ -z "${BUILD_NUM_OFFSET}" ]]
then
BUILD_NUM=$((GITHUB_RUN_NUMBER+BUILD_NUM_OFFSET))
fi
version+=+$BUILD_NUM
export TRAVIS_BUILD_NUMBER=${BUILD_NUM}
fi
echo "======================================"
echo "Building version ${version}"
echo "======================================"
if [[ "$DISABLE_BUILD_SCAN" == "true" ]]; then
./gradlew $GRADLE_PARAMS -Prelease="${version}"
else
./gradlew $GRADLE_PARAMS -Prelease="${version}" --scan
fi
fi