Skip to content

Commit

Permalink
Devkit publish tool updates to support publishing devkit binaries to h…
Browse files Browse the repository at this point in the history
…ttps://github.com/adoptium/devkit-binaries (#152)

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add publish DevKit script

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Publiush a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Publiush a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

---------

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
  • Loading branch information
andrew-m-leonard authored Apr 4, 2024
1 parent 6081776 commit 2dc9131
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 11 deletions.
2 changes: 1 addition & 1 deletion adopt-github-release/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}
application {
mainClassName = 'net.adoptium.release.UploadFiles'
applicationDefaultJvmArgs = ['-Xmx2g']
applicationDefaultJvmArgs = ['-Xmx4g']
}

dependencies {
Expand Down
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

0 comments on commit 2dc9131

Please sign in to comment.