From 074cac66769f9d8857a05c62e76fda8c0a5875e4 Mon Sep 17 00:00:00 2001 From: Steven Gueguen Date: Fri, 10 Nov 2023 17:39:37 +0100 Subject: [PATCH 1/5] Add release artifacts --- Jenkinsfile | 98 +++++++++++++++++++---------------- warp10/src/main/sh/package.sh | 9 +++- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2145fb5f3..cf90a4c254 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,54 +68,62 @@ pipeline { } } - stage('Deploy libs to SenX\' Nexus') { - options { - timeout(time: 2, unit: 'HOURS') - } - input { - message "Should we deploy libs?" - } - steps { - sh "$GRADLE_CMD publishMavenPublicationToNexusRepository -x test" - } - } - - stage('Release tar.gz on GitHub') { + stage('Publish') { when { - beforeInput true - // Only possible if code pulled from github because the release will refer to the - // given tag in the given branch. If no such tag exists, it is created from the - // HEAD of the branch. - expression { return 'github.com' == getParam('gitHost') } - } - options { - timeout(time: 2, unit: 'HOURS') - } - input { - message "Should we release Warp 10?" + expression { "" != ${TAG} } } - steps { - script { - releaseID = createGitHubRelease() + stages { + stage('Deploy libs to SenX\' Nexus') { + options { + timeout(time: 24, unit: 'HOURS') + } + input { + message "Should we deploy libs?" + } + steps { + sh "$GRADLE_CMD publishMavenPublicationToNexusRepository -x test" + } } - sh "curl -f -X POST -H \"Authorization:token ${getParam('githubToken')}\" -H \"Content-Type:application/octet-stream\" -T warp10/build/libs/warp10-${VERSION}.tar.gz https://uploads.github.com/repos/${getParam('gitOwner')}/${getParam('gitRepo')}/releases/${releaseID}/assets?name=warp10-${VERSION}.tar.gz" - } - } - stage('Deploy libs to Maven Central') { - options { - timeout(time: 2, unit: 'HOURS') - } - input { - message "Should we deploy libs?" - } - steps { - sh "$GRADLE_CMD publish" - sh "$GRADLE_CMD closeRepository" - sh "$GRADLE_CMD releaseRepository" - notifyBuild('PUBLISHED') - } - } + stage('Release tar.gz on GitHub') { + when { + beforeInput true + // Only possible if code pulled from github because the release will refer to the + // given tag in the given branch. If no such tag exists, it is created from the + // HEAD of the branch. + expression { return 'github.com' == getParam('gitHost') } + } + options { + timeout(time: 2, unit: 'HOURS') + } + input { + message "Should we release Warp 10?" + } + steps { + script { + releaseID = createGitHubRelease() + } + sh "curl -f -X POST -H \"Authorization:token ${getParam('githubToken')}\" -H \"Content-Type:application/octet-stream\" -T warp10/build/libs/warp10-${VERSION}.tar.gz https://uploads.github.com/repos/${getParam('gitOwner')}/${getParam('gitRepo')}/releases/${releaseID}/assets?name=warp10-${VERSION}.tar.gz" + sh "curl -f -X POST -H \"Authorization:token ${getParam('githubToken')}\" -H \"Content-Type:application/octet-stream\" -T warp10/build/libs/warp10-${VERSION}.tar.gz.asc https://uploads.github.com/repos/${getParam('gitOwner')}/${getParam('gitRepo')}/releases/${releaseID}/assets?name=warp10-${VERSION}.tar.gz.asc" + sh "curl -f -X POST -H \"Authorization:token ${getParam('githubToken')}\" -H \"Content-Type:application/octet-stream\" -T warp10/build/libs/warp10-${VERSION}.tar.gz.sha512 https://uploads.github.com/repos/${getParam('gitOwner')}/${getParam('gitRepo')}/releases/${releaseID}/assets?name=warp10-${VERSION}.tar.gz.sha512" + } + } + + stage('Deploy libs to Maven Central') { + options { + timeout(time: 2, unit: 'HOURS') + } + input { + message "Should we deploy libs?" + } + steps { + sh "$GRADLE_CMD publish" + sh "$GRADLE_CMD closeRepository" + sh "$GRADLE_CMD releaseRepository" + notifyBuild('PUBLISHED') + } + } + } } @@ -181,5 +189,5 @@ String getVersion() { } String getTag() { - return sh(returnStdout: true, script: 'git describe --tags').trim() + return sh(returnStdout: true, script: 'git tag --points-at HEAD').trim() } diff --git a/warp10/src/main/sh/package.sh b/warp10/src/main/sh/package.sh index 5fc81d3336..adfa210bf5 100755 --- a/warp10/src/main/sh/package.sh +++ b/warp10/src/main/sh/package.sh @@ -113,7 +113,14 @@ find "${WARP10_HOME}" -type f \( -name \*.sh -o -name \*.py -o -name \*.init \) chmod 700 "${WARP10_HOME}/etc" # Build tar -tar czpf "../build/libs/warp10-${VERSION}.tar.gz" "${WARP10_HOME}" +FILE=../build/libs/warp10-${VERSION}.tar.gz +tar czpf "${FILE}" "${WARP10_HOME}" + +# Generate signature +gpg --local-user BD49DA0A --output "${FILE}".asc --detach-sign "${FILE}" + +# Generate hash +sha512sum "${FILE}" | sed -e "s@ .*/@ @" > "${FILE}".sha512 # Delete ARCHIVE rm -rf "${ARCHIVE}" From c1cc63d2bf8f69838d05c78ef4ed96f01cf0a507 Mon Sep 17 00:00:00 2001 From: Steven Gueguen Date: Fri, 10 Nov 2023 17:48:11 +0100 Subject: [PATCH 2/5] Missing curly braces --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cf90a4c254..c4bfc40a7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -123,8 +123,8 @@ pipeline { notifyBuild('PUBLISHED') } } - } - + } + } } post { From 174c64500897e1fd58c56c62cc476a056f4493e0 Mon Sep 17 00:00:00 2001 From: Steven Gueguen Date: Fri, 10 Nov 2023 17:58:05 +0100 Subject: [PATCH 3/5] Fix var --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c4bfc40a7d..eb54052f28 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,7 +70,7 @@ pipeline { stage('Publish') { when { - expression { "" != ${TAG} } + expression { "" != TAG } } stages { stage('Deploy libs to SenX\' Nexus') { From 12a95761e9644c36ce1602b4837c3ff78a9b900a Mon Sep 17 00:00:00 2001 From: Steven Gueguen Date: Fri, 10 Nov 2023 18:01:54 +0100 Subject: [PATCH 4/5] Add gradlew clean --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index eb54052f28..dbdc55edc6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,7 +47,7 @@ pipeline { stage('Build') { steps { - sh "$GRADLE_CMD build -x test" + sh "$GRADLE_CMD clean build -x test" archiveArtifacts allowEmptyArchive: true, artifacts: '**/build/libs/*.jar', fingerprint: true } } From 7c9688ef620d334acba684f57f96c9f9313047b5 Mon Sep 17 00:00:00 2001 From: Steven Gueguen Date: Wed, 15 Nov 2023 14:54:28 +0100 Subject: [PATCH 5/5] Use a parameter for GPG key --- warp10/build.gradle | 2 +- warp10/src/main/sh/package.sh | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/warp10/build.gradle b/warp10/build.gradle index fbc2c47ec9..bc4857f808 100644 --- a/warp10/build.gradle +++ b/warp10/build.gradle @@ -183,7 +183,7 @@ task pack(type: Jar) { // task createTarArchive(type: Exec, dependsOn: pack) { workingDir '.' - commandLine "${projectDir}/src/main/sh/package.sh", version, projectDir + commandLine "${projectDir}/src/main/sh/package.sh", version, projectDir, project.getProperties().get("signing.gnupg.keyName") outputs.file "${buildDir}/libs/warp10-${version}.tar.gz" } diff --git a/warp10/src/main/sh/package.sh b/warp10/src/main/sh/package.sh index adfa210bf5..9ed36e5ab3 100755 --- a/warp10/src/main/sh/package.sh +++ b/warp10/src/main/sh/package.sh @@ -32,7 +32,7 @@ set -eu VERSION=$1 if [ -z "${VERSION:+x}" ]; then - echo "Usage: $0 VERSION WARP_ROOT_PATH" + echo "Usage: $0 VERSION WARP_ROOT_PATH GPG_KEY_NAME" exit 1 fi WARP10_HOME=warp10-${VERSION} @@ -40,7 +40,7 @@ WARP10_HOME=warp10-${VERSION} # Warp 10 root project path (../warp10) WARP_ROOT_PATH=$2 if [ -z "${WARP_ROOT_PATH:+x}" ]; then - echo "Usage: $0 VERSION WARP_ROOT_PATH" + echo "Usage: $0 VERSION WARP_ROOT_PATH GPG_KEY_NAME" exit 1 fi if [ ! -d "${WARP_ROOT_PATH}" ]; then @@ -48,6 +48,12 @@ if [ ! -d "${WARP_ROOT_PATH}" ]; then exit 1 fi +GPG_KEY_NAME=$3 +if [ -z "${GPG_KEY_NAME:+x}" ]; then + echo "Usage: $0 VERSION WARP_ROOT_PATH GPG_KEY_NAME" + exit 1 +fi + ARCHIVE=${WARP_ROOT_PATH}/archive # Remove existing archive dir @@ -117,7 +123,7 @@ FILE=../build/libs/warp10-${VERSION}.tar.gz tar czpf "${FILE}" "${WARP10_HOME}" # Generate signature -gpg --local-user BD49DA0A --output "${FILE}".asc --detach-sign "${FILE}" +gpg --local-user "${GPG_KEY_NAME}" --output "${FILE}".asc --detach-sign "${FILE}" # Generate hash sha512sum "${FILE}" | sed -e "s@ .*/@ @" > "${FILE}".sha512