diff --git a/adopt-github-release/src/main/groovy/net/adoptium/release/UploadFiles.groovy b/adopt-github-release/src/main/groovy/net/adoptium/release/UploadFiles.groovy index 708f55e..b9a0460 100644 --- a/adopt-github-release/src/main/groovy/net/adoptium/release/UploadFiles.groovy +++ b/adopt-github-release/src/main/groovy/net/adoptium/release/UploadFiles.groovy @@ -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 files) { + UploadAdoptReleaseFiles(String tag, String description, boolean release, boolean isDevKit, boolean isPkgSrc, String version, String server, String org, List 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 @@ -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 { @@ -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]/, "") @@ -133,6 +137,7 @@ static void main(String[] args) { options.d, options.r, options.k, + options.p, options.v, options.s, options.o, @@ -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' diff --git a/sbin/PublishPkgSrc.sh b/sbin/PublishPkgSrc.sh new file mode 100644 index 0000000..66b63bf --- /dev/null +++ b/sbin/PublishPkgSrc.sh @@ -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 +# +# Updated Filename Validation Logic +# +################################################################### +set -eo pipefail + +# Validate filenames matching: Package_Bld_Src_ + (linux|alpine-linux) + jdk + .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"