-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-maven.sh
executable file
·62 lines (48 loc) · 1.63 KB
/
build-maven.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
#!/bin/bash
set -eu
# Set a default JAVA_TOOL_OPTIONS if it hasn't already been specified
export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS:--Xmx8192m}"
DISABLE_CHECKSTYLE=${DISABLE_CHECKSTYLE:-false}
if [[ $(git rev-parse --is-shallow-repository) == "true" ]]
then
git fetch --unshallow
fi
if [ -z ${GITHUB_RUN_NUMBER+x} ]; then
if [[ "$DISABLE_CHECKSTYLE" == "true" ]]; then
mvn package
else
mvn -Plibrary verify
fi
else
version=""
snapshot=true
echo "GITHUB_ACTIONS_TAG ${GITHUB_ACTIONS_TAG}"
echo "GITHUB_ACTIONS_PULL_REQUEST ${GITHUB_ACTIONS_PULL_REQUEST}"
if [[ ! -z "$GITHUB_ACTIONS_PULL_REQUEST" ]]; then
version="PR$GITHUB_ACTIONS_PULL_REQUEST"
elif [[ "$GITHUB_ACTIONS_TAG" =~ ^v[0-9]+\. ]]; then
version=${GITHUB_ACTIONS_TAG/v/}
snapshot=false
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 "======================================"
mvn -B versions:set -DnewVersion="${version}"
if [[ "$DISABLE_CHECKSTYLE" == "true" ]]; then
mvn -B package
else
mvn -B -Plibrary verify
fi
fi