-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·49 lines (39 loc) · 1.51 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.51 KB
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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
. .env
export MAVEN_OPTS="${MAVEN_OPTS:-} --enable-native-access=ALL-UNNAMED --sun-misc-unsafe-memory-access=allow"
: "${MVN_SETTINGS:?MVN_SETTINGS must point to the Maven settings directory}"
for command in mvn curl gpg; do
command -v "$command" >/dev/null 2>&1 || {
printf 'Required command not found: %s\n' "$command" >&2
exit 127
}
done
project_value() {
mvn --batch-mode --no-transfer-progress -q help:evaluate -Dexpression="$1" -DforceStdout
}
group_id="$(project_value project.groupId)"
artifact_id="$(project_value project.artifactId)"
version="$(project_value project.version)"
central_url="https://repo1.maven.org/maven2/${group_id//.//}/$artifact_id/$version/$artifact_id-$version.pom"
if ! http_code="$(curl --silent --show-error --location --output /dev/null \
--connect-timeout 10 --max-time 30 --write-out '%{http_code}' "$central_url")"; then
printf 'Maven Central could not be reached; deployment skipped\n' >&2
exit 1
fi
case "$http_code" in
200)
printf 'Already published on Maven Central: %s:%s:%s\n' \
"$group_id" "$artifact_id" "$version"
exit 0
;;
404) ;;
*)
printf 'Maven Central returned HTTP %s; deployment skipped\n' "$http_code" >&2
exit 1
;;
esac
gpg --batch --yes --pinentry-mode loopback --import "$MVN_SETTINGS/gpg-private.asc"
exec mvn --batch-mode --no-transfer-progress clean deploy -e -Prelease \
-s "$MVN_SETTINGS/maven-settings.xml"