-
Notifications
You must be signed in to change notification settings - Fork 8
/
release.sh
executable file
·130 lines (101 loc) · 4.65 KB
/
release.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
# Steps to create a BDeploy release.
#
# Requires two arguments: the version to release and the new version number after the release.
#
# Following environment variables are supported:
# GH_USER (required): the username to use when pushing or publishing a release.
# GH_TOKEN (required): the token to use when pushing or publishing a release. GH_USER and GH_TOKEN must match.
# NO_TESTS (optional): whether to skip tests.
# JDK_DL_ROOT (optional): directory where JDKs should be downloaded automatically. If not set, JDKs must be setup correctly on the machine in gradle.properties.
# JDK_DL_CLEAN (optional): remove existing JDKs and re-download the current latest version. If a JDK already exists, it will be re-used no matter what version if not cleaning.
# GRADLE_ARGS (optional): additional gradle arguments
ROOT=$(cd $(dirname $0); pwd)
cd "$ROOT"
REL_VER="$1"
NEXT_VER="$2"
GRADLE_ARG_ARR=( $GRADLE_ARGS )
die() {
echo "ERROR:" "$@" 1>&2
exit 1
}
if [[ -z "${REL_VER}" ]]; then
die "First argument must be the version to release"
fi
if [[ -z "${NEXT_VER}" ]]; then
die "Second argument must be the next version to use"
fi
if [[ -z "${GH_USER}" ]]; then
die "GH_USER variable must contain the GitHub user which is allowed to push and create a release"
fi
if [[ -z "${GH_TOKEN}" ]]; then
die "GH_TOKEN variable must contain the GitHub token which is allowed to create a release"
fi
if [[ -z "${SONATYPE_USER}" ]]; then
die "SONATYPE_USER variable must contain the Nexus user which is allowed to push and create a release"
fi
if [[ -z "${SONATYPE_TOKEN}" ]]; then
die "SONATYPE_TOKEN variable must contain the Nexus token which is allowed to create a release"
fi
if [[ -z "${GPG_ID}" ]]; then
die "GPG_ID variable must contain the GPG Key which is used to signe artifacts"
fi
if [[ -z "${GPG_PASS}" ]]; then
die "GPG_PASS variable must contain the passphrase for the GPG Key"
fi
if [[ -z "${GPG_FILE}" ]]; then
die "GPG_FILE variable must contain the path to the GPG Keyring file"
fi
CURRENT_VER="$(cat "$ROOT/bdeploy.version")"
if [[ ${CURRENT_VER} != *"-SNAPSHOT" ]]; then
die "Current version ($CURRENT_VER) is not a SNAPSHOT version!"
fi
if [[ ${NEXT_VER} != *"-SNAPSHOT" ]]; then
die "Next version ($NEXT_VER) must be a SNAPSHOT version!"
fi
if [[ ! ${REL_VER} =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
die "Release version ($REL_VER) format does not match MAJOR.MINOR.MICRO"
fi
echo "Releasing $REL_VER from current $CURRENT_VER, updating to $NEXT_VER. OK?"
read ok
set -e
if [[ -n "${JDK_DL_ROOT}" ]]; then
r="${JDK_DL_ROOT}/jdks"
if [[ -d "${r}" && -n "${JDK_DL_CLEAN}" ]]; then
echo "Removing old JDKs in $r"
rm -rf "${r}"
fi
if [[ ! -d "${r}/linux64" ]]; then
mkdir -p "${r}/linux64"
curl -L "https://api.adoptium.net/v3/binary/latest/21/ga/linux/x64/jdk/hotspot/normal/adoptium?project=jdk" --output "${r}/jdk-linux64.tar.gz"
(
cd "${r}/linux64"
tar xfz "${r}/jdk-linux64.tar.gz" > /dev/null
)
fi
v=$(find "${r}/linux64/" -maxdepth 1 -type d -not -name 'linux64' -name '[^.]?*' -printf %f -quit)
GRADLE_ARG_ARR+=( "-Dlinux64jdk=${r}/linux64/${v}" )
if [[ ! -d "${r}/win64" ]]; then
mkdir -p "${r}/win64"
curl -L "https://api.adoptium.net/v3/binary/latest/21/ga/windows/x64/jdk/hotspot/normal/adoptium?project=jdk" --output "${r}/jdk-win64.zip"
(
cd "${r}/win64"
unzip "${r}/jdk-win64.zip" > /dev/null
)
fi
v=$(find "${r}/win64/" -maxdepth 1 -type d -not -name 'win64' -name '[^.]?*' -printf %f -quit)
GRADLE_ARG_ARR+=( "-Dwin64jdk=${r}/win64/${v}" )
fi
./gradlew setVersion -PtargetVersion=$REL_VER "${GRADLE_ARG_ARR[@]}"
[[ -n "${NO_TESTS}" ]] && ./gradlew clean build release updateDocuScreenshots -x test -x releaseTest -x runCypressHeadless "${GRADLE_ARG_ARR[@]}"
[[ -z "${NO_TESTS}" ]] && ./gradlew clean build release updateDocuScreenshots -x releaseTest "${GRADLE_ARG_ARR[@]}"
[[ -z "${NO_MAVEN}" ]] && ./gradlew publish -PsonatypeUser=$SONATYPE_USER -PsonatypeToken=$SONATYPE_TOKEN -Psigning.keyId=$GPG_ID -Psigning.password=$GPG_PASS -Psigning.secretKeyRingFile=$GPG_FILE "${GRADLE_ARG_ARR[@]}"
git add bdeploy.version doc
git commit -m "Release $REL_VER"
git push https://$GH_USER:$GH_TOKEN@github.com/bdeployteam/bdeploy.git HEAD:master
./gradlew githubRelease -PgithubToken=$GH_TOKEN "${GRADLE_ARG_ARR[@]}"
./gradlew setVersion -PtargetVersion=$NEXT_VER "${GRADLE_ARG_ARR[@]}"
[[ -z "${NO_TESTS}" ]] && ./gradlew build releaseTest -x test -x runCypressHeadless "${GRADLE_ARG_ARR[@]}"
git add bdeploy.version
git commit -m "Update to $NEXT_VER"
echo "Done."