Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/setup-ja…
Browse files Browse the repository at this point in the history
…va-4.0.0
  • Loading branch information
karianna authored Apr 4, 2024
2 parents 40abcc6 + 2dc9131 commit 3b6d11d
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 17 deletions.
5 changes: 3 additions & 2 deletions adopt-github-release/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ repositories {
}
application {
mainClassName = 'net.adoptium.release.UploadFiles'
applicationDefaultJvmArgs = ['-Xmx4g']
}

dependencies {
implementation 'org.codehaus.groovy:groovy-all:2.5.6'
implementation 'org.kohsuke:github-api:1.127'
implementation 'org.codehaus.groovy:groovy-all:3.0.20'
implementation 'org.kohsuke:github-api:1.318'
compileOnly group: 'junit', name: 'junit', version: '4.12'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,26 @@ class UploadAdoptReleaseFiles {
private final String version
private final String server
private final String org
private final boolean isDevKit

UploadAdoptReleaseFiles(String tag, String description, boolean release, String version, String server, String org, List<File> files) {
UploadAdoptReleaseFiles(String tag, String description, boolean release, boolean isDevKit, String version, String server, String org, List<File> files) {
this.tag = tag
this.description = description
this.release = release
this.isDevKit = isDevKit
this.files = files
this.version = version
this.server = server
this.org = org
}

void release() {
def grouped = files.groupBy {
GHRepository repo = getRepo("adopt")
GHRelease release = getRelease(repo)
if (isDevKit) {
uploadFiles(release, files)
} else {
def grouped = files.groupBy {
switch (it.getName()) {
// Only release file names containing certain patterns
// to avoid publication of non-temurin builds
Expand All @@ -40,10 +47,9 @@ class UploadAdoptReleaseFiles {
case ~/.*release-notes.*/: "adopt"; break;
case ~/.*AQAvitTapFiles.*/: "adopt"; break;
}
}
uploadFiles(release, grouped.get("adopt"))
}
GHRepository repo = getRepo("adopt")
GHRelease release = getRelease(repo)
uploadFiles(release, grouped.get("adopt"))
}

private GHRepository getRepo(String vendor) {
Expand All @@ -66,12 +72,18 @@ class UploadAdoptReleaseFiles {
(int) TimeUnit.SECONDS.toMillis(120)))

println("Using Github org:'${org}'")
// jdk11 => 11
def numberVersion = version.replaceAll(/[^0-9]/, "")
def repoName = "${org}/temurin${numberVersion}-binaries"

if (vendor != "adopt") {
repoName = "${org}/open${version}-${vendor}-binaries"
def repoName
if (isDevKit) {
repoName = "${org}/devkit-binaries"
} else {
// jdk11 => 11
def numberVersion = version.replaceAll(/[^0-9]/, "")
repoName = "${org}/temurin${numberVersion}-binaries"

if (vendor != "adopt") {
repoName = "${org}/open${version}-${vendor}-binaries"
}
}

return github.getRepository(repoName)
Expand Down Expand Up @@ -120,6 +132,7 @@ static void main(String[] args) {
options.t,
options.d,
options.r,
options.k,
options.v,
options.s,
options.o,
Expand All @@ -137,6 +150,7 @@ private OptionAccessor parseArgs(String[] args) {
t longOpt: 'tag', type: String, args: 1, 'Tag name'
d longOpt: 'description', type: String, args: 1, 'Release description'
r longOpt: 'release', 'Is a release build'
k longOpt: 'isDevKit', 'Is a DevKit build'
h longOpt: 'help', 'Show usage information'
s longOpt: 'server', type: String, args: 1, optionalArg: true, defaultValue: 'https://api.github.com', 'Github server'
o longOpt: 'org', type: String, args: 1, optionalArg: true, defaultValue: 'adoptium', 'Github org'
Expand Down
96 changes: 96 additions & 0 deletions sbin/PublishDevKit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

###################################################################
#
# PublishDevKit.sh TAG <GITHUB_SERVER> <GITHUB_ORG>
#
# This script will take the passed in TAG
# then use a Groovy scripy with the Github API to create a
# release (or update an existing release) up in GitHub
#
###################################################################
set -eo pipefail

# eg: artifact:
# devkit-gcc-11.3.0-Centos7.6.1810-b01-x86_64-linux-gnu.tar.gz

# (compiler ) (version ) (sysroot ) (build )-(arch )(suffix ) (extension )
regex="^devkit-([[:alnum:]]+)-([[:digit:]\.]+)-([[:alnum:]\.]+)-([[:alnum:]]+)-([[:alnum:]\_]+)(-linux-gnu)\.(tar\.xz|tar\.xz\.sha256\.txt|tar\.xz\.sig)$";

# Check that a TAG has been passed in.
if [ -z "${TAG}" ]; then
echo "Must have a tag set"
exit 1
fi

# Set the GitHub server to push to
if [ -z "${GITHUB_SERVER}" ]; then
server=""
else
server="--server \"${GITHUB_SERVER}\""
fi

# Set the GitHub org to push to
if [ -z "${GITHUB_ORG}" ]; then
org=""
else
org="--org \"${GITHUB_ORG}\""
fi

# Validate all file names with regex
valid_files=true
for file in devkit-*
do
if [[ $file =~ $regex ]];
then
echo "DevKit file: $file"
FILE_COMPILER=${BASH_REMATCH[1]};
FILE_VERSION=${BASH_REMATCH[2]};
FILE_SYSROOT=${BASH_REMATCH[3]};
FILE_BUILD=${BASH_REMATCH[4]};
FILE_ARCH=${BASH_REMATCH[5]};
FILE_SUFFIX=${BASH_REMATCH[6]};
FILE_EXTENSION=${BASH_REMATCH[7]};

file_tag="${FILE_COMPILER}-${FILE_VERSION}-${FILE_SYSROOT}-${FILE_BUILD}"

# Validate tarball is valid for publishing as TAG release
if [[ "${file_tag}" != "${TAG}" ]]; then
echo "ERROR: devkit file is not valid for publishing under release tag ${TAG} : ${file}"
valid_files=false
fi
else
echo "ERROR: devkit file does not match required regex pattern: ${file}"
valid_files=false
fi
done

if [ "$valid_files" == "false" ]; then
echo "ERROR: Some devkit filenames are not valid..."
exit 1
fi

files=$(find $PWD \( -name "devkit-*" \) | tr '\n' ' ')

if [ "$DRY_RUN" == "false" ]; then
description="Release of $TAG"

# Hand over to the Groovy script that uses the GitHub API to actually create the release and upload files
cd adopt-github-release || exit 1
chmod +x gradlew
GRADLE_USER_HOME=./gradle-cache ./gradlew --no-daemon run --args="--isDevKit --release --version \"${TAG}\" --tag \"${TAG}\" --description \"${description}\" ${server} ${org} $files"
fi

5 changes: 3 additions & 2 deletions sbin/Release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ timestampRegex="[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}-[[:digit:]]{2}-[[:d
# OpenJDK 18U -jdk-sources 2020-06-06-16-36 .tar.gz
# OpenJDK 11_ -jdk x64_ linux_ _fast_startup_ 11_28 .tar.gz
# OpenJDK -debugimage aarch64_ linux_ hotspot_ 2023-02-16-12-32 .tar.gz
# OpenJDK 17U_ -jdk x64_ linux_ hotspot_ 17.0.10_5-ea .tar.gz
#
# (version ) (type ) (arch ) (os ) (variant ) (timestamp or version ) (extension )
regex="OpenJDK([[:digit:]]*)U?(-jre|-jdk|-debugimage|-static-libs-glibc|-static-libs|-static-libs-musl|-testimage|-jdk-sources)_([[:alnum:]\-]+_)?([[:alnum:]\-]+_)?([[:alnum:]\-_]+_)?([[:digit:]\-]+|[[:alnum:]\._]+)\.(tar\.gz|zip|pkg|msi)";
# (version ) (type ) (arch ) (os ) (variant ) (timestamp or version ) (extension )
regex="OpenJDK([[:digit:]]*)U?(-jre|-jdk|-debugimage|-static-libs-glibc|-static-libs|-static-libs-musl|-testimage|-jdk-sources)_([[:alnum:]\-]+_)?([[:alnum:]\-]+_)?([[:alnum:]\-_]+_)?([[:digit:]\-]+|[[:alnum:]\._\-]+)\.(tar\.gz|zip|pkg|msi)";

regexArchivesOnly="${regex}$";

Expand Down
4 changes: 2 additions & 2 deletions sbin/releaseCheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo Grabbing information from https://github.com/adoptium/temurin${TEMURIN_VERS
FILTER=$(echo $TEMURIN_TAG | sed 's/+/%2B/g')
echo FILTER IS: $FILTER
curl -q https://api.github.com/repos/adoptium/temurin${TEMURIN_VERSION}-binaries/releases |
grep "$FILTER" |
grep "/$FILTER/" |
awk -F'"' '/browser_download_url/{print$4}' > releaseCheck.$$.tmp || exit 1

#### LINUX (ALL)
Expand Down Expand Up @@ -59,7 +59,7 @@ done
### Alpine - Same number of artifacts as Linux so don't adjust EXPECTED
for ARCH in x64 aarch64; do
# Alpine/aarch64 is only included from JDK21
if [ "${TEMURIN_VERSION}" -ge 21 -o "${ARCH}" == "x64" ]; then
if [ "${TEMURIN_VERSION}" -ge 21 -o "${ARCH}" = "x64" ]; then
ACTUAL=$(cat releaseCheck.$$.tmp | grep ${ARCH}_alpine | wc -l)
if [ $ACTUAL -eq $EXPECTED ]
then
Expand Down

0 comments on commit 3b6d11d

Please sign in to comment.