diff --git a/Jenkinsfile b/Jenkinsfile index a2145fb5f..dbdc55edc 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 } } @@ -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 { @@ -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/build.gradle b/warp10/build.gradle index fbc2c47ec..bc4857f80 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 5fc81d333..9ed36e5ab 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 @@ -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}"