Skip to content

Commit

Permalink
Add functionality to upload installer pkg source archives. (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
steelhead31 authored Jan 20, 2025
1 parent d9606ea commit 5896375
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ class UploadAdoptReleaseFiles {
private final String server
private final String org
private final boolean isDevKit
private final boolean isPkgSrc

UploadAdoptReleaseFiles(String tag, String description, boolean release, boolean isDevKit, String version, String server, String org, List<File> files) {
UploadAdoptReleaseFiles(String tag, String description, boolean release, boolean isDevKit, boolean isPkgSrc, String version, String server, String org, List<File> files) {
this.tag = tag
this.description = description
this.release = release
this.isDevKit = isDevKit
this.isDevKit = isDevKit
this.isPkgSrc = isPkgSrc
this.files = files
this.version = version
this.server = server
Expand All @@ -35,7 +37,7 @@ class UploadAdoptReleaseFiles {
void release() {
GHRepository repo = getRepo("adopt")
GHRelease release = getRelease(repo)
if (isDevKit) {
if (isDevKit || isPkgSrc) {
uploadFiles(release, files)
} else {
def grouped = files.groupBy {
Expand Down Expand Up @@ -76,6 +78,8 @@ class UploadAdoptReleaseFiles {
def repoName
if (isDevKit) {
repoName = "${org}/devkit-binaries"
} else if (isPkgSrc) {
repoName = "${org}/temurin-linux-pkg-sources"
} else {
// jdk11 => 11
def numberVersion = version.replaceAll(/[^0-9]/, "")
Expand Down Expand Up @@ -133,6 +137,7 @@ static void main(String[] args) {
options.d,
options.r,
options.k,
options.p,
options.v,
options.s,
options.o,
Expand All @@ -151,6 +156,7 @@ private OptionAccessor parseArgs(String[] args) {
d longOpt: 'description', type: String, args: 1, 'Release description'
r longOpt: 'release', 'Is a release build'
k longOpt: 'isDevKit', 'Is a DevKit build'
p longOpt: 'isPkgSrc', 'Is a linux package src 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
70 changes: 70 additions & 0 deletions sbin/PublishPkgSrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/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,
# 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.
#

###################################################################
#
# PublishPkgSrc.sh TAG <GITHUB_SERVER> <GITHUB_ORG>
#
# Updated Filename Validation Logic
#
###################################################################
set -eo pipefail

# Validate filenames matching: Package_Bld_Src_ + (linux|alpine-linux) + jdk<anything> + .tar.gz
regex="^Package_Bld_Src_(linux|alpine-linux)_jdk.*\.tar\.gz$"

# 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 Package_Bld_Src_*
do
if [[ $file =~ $regex ]]; then
echo "Valid file: $file"
else
echo "ERROR: File does not match the required pattern: ${file}"
valid_files=false
fi
done

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

files=$(find $PWD \( -name "Package_Bld_Src_*" \) | tr '\n' ' ')
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="--isPkgSrc --release --version \"${TAG}\" --tag \"${TAG}\" --description \"${description}\" ${server} ${org} $files"

0 comments on commit 5896375

Please sign in to comment.