Skip to content

Commit

Permalink
Merge pull request #1329 from steven-gueguen/release-artifacts
Browse files Browse the repository at this point in the history
Release artifacts
  • Loading branch information
hbs authored Nov 15, 2023
2 parents 46c871c + 7c9688e commit 2c46266
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 49 deletions.
98 changes: 53 additions & 45 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -68,55 +68,63 @@ 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')
}
}
}
}

}

post {
Expand Down Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion warp10/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
19 changes: 16 additions & 3 deletions warp10/src/main/sh/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,28 @@ 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}

# 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
echo "${WARP_ROOT_PATH} folder does not exist."
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
Expand Down Expand Up @@ -113,7 +119,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 "${GPG_KEY_NAME}" --output "${FILE}".asc --detach-sign "${FILE}"

# Generate hash
sha512sum "${FILE}" | sed -e "s@ .*/@ @" > "${FILE}".sha512

# Delete ARCHIVE
rm -rf "${ARCHIVE}"

0 comments on commit 2c46266

Please sign in to comment.