-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-jdk.sh
executable file
·80 lines (71 loc) · 2.83 KB
/
upload-jdk.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
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o noclobber
set -o nounset
#set -o xtrace #debug
## Publish JDK
## ===========
## Publishes the various versions of a JDK to Metaborg Artifacts.
##
## 1. Preparation: ensure `~/.m2/settings.xml` contains the following (where $username and $password
## are your Metaborg Artifacts username and password):
##
## <?xml version="1.0" ?>
## <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
## xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
## <profiles>
## <profile>
## <id>metaborg-release-repos</id>
## <repositories>
## <repository>
## <id>metaborg-release-repo</id>
## <url>https://artifacts.metaborg.org/content/repositories/releases/</url>
## </repository>
## </repositories>
## </profile>
## </profiles>
## <servers>
## <server>
## <id>metaborg-release-repo</id>
## <username>$username</username>
## <password>$password</password>
## </server>
## </servers>
## </settings>
##
## 2. Download from https://adoptium.net/temurin/releases/?version=17 and place in the current directory:
## - Temurin 17 Linux aarch64 JDK .tar.gz
## - Temurin 17 Linux x64 JDK .tar.gz
## - Temurin 17 macOS aarch64 JDK .tar.gz
## - Temurin 17 macOS x64 JDK .tar.gz
## - Temurin 17 Windows x64 JDK .zip
##
## 3. Invoke this script in the current directory.
##
# Settings
repo_id="metaborg-release-repo" # From ~/.m2/settings.xml
repo_url="https://artifacts.metaborg.org/content/repositories/releases/"
artifact_group="net.adoptium"
artifact_id="jdk"
# Find the JDK files to deploy
regex="^[a-zA-z0-9]*-jdk_([a-zA-Z0-9\-]+)_([a-zA-Z0-9]+)_[a-zA-Z0-9]+_([0-9\.\-\_]+)\.(tar\.gz|zip)$" # Must be in variable
for file in *.{zip,tar.gz} # Allow glob expansion
do
if [[ $file =~ $regex ]]
then
# Filename matches pattern
artifact_version="${BASH_REMATCH[3]/_/-}" # E.g., "17.0.11-9"
artifact_classifier="${BASH_REMATCH[2]/#mac/macosx}-${BASH_REMATCH[1]}" # E.g., "macosx-aarch64"
echo "Deploying ${artifact_group}:${artifact_id}:${artifact_version} for ${artifact_classifier}..."
mvn deploy:deploy-file \
--quiet \
"-Durl=${repo_url}" \
"-DrepositoryId=${repo_id}" \
"-DgroupId=${artifact_group}" \
"-DartifactId=${artifact_id}" \
"-Dversion=${artifact_version}" \
"-Dclassifier=${artifact_classifier}" \
"-Dfile=${file}"
fi
done