From 5af3223e7621004992fa6410d2e6a82be238fd8b Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 7 May 2020 21:35:56 +0200 Subject: [PATCH] Add Release pipeline for Milestone versions This commit finishes the first step for migrating our complete build and release pipeline to Concourse CI. We're creating here a new "Release" jobs group in our pipeline. We can now release Milestones from our pipeline with: * the "stage-milestone" job, which creates and tags a new Milestone version on the source repository, builds the artifacts and deploys them in a staging repository and updates the version to the next SNAPSHOT. * the "promote-milestone" fetches the build information from the staging repository and promotes the released milestone in the official milestone repository. Interactions with the Artifactory and Bintray REST APIs are done using the https://github.com/spring-io/concourse-release-scripts project. Closes gh-22490 --- ci/images/setup.sh | 1 + ci/pipeline.yml | 43 ++++++++++++++++++++++++++++++ ci/scripts/promote-version.sh | 13 +++++++++ ci/scripts/stage-version.sh | 50 +++++++++++++++++++++++++++++++++++ ci/tasks/promote-version.yml | 18 +++++++++++++ ci/tasks/stage-version.yml | 17 ++++++++++++ 6 files changed, 142 insertions(+) create mode 100755 ci/scripts/promote-version.sh create mode 100755 ci/scripts/stage-version.sh create mode 100644 ci/tasks/promote-version.yml create mode 100644 ci/tasks/stage-version.yml diff --git a/ci/images/setup.sh b/ci/images/setup.sh index 6e936491afc1..52c5d718d074 100755 --- a/ci/images/setup.sh +++ b/ci/images/setup.sh @@ -11,6 +11,7 @@ rm -rf /var/lib/apt/lists/* curl https://raw.githubusercontent.com/spring-io/concourse-java-scripts/v0.0.3/concourse-java.sh > /opt/concourse-java.sh +curl --output /opt/concourse-release-scripts.jar https://repo.spring.io/release/io/spring/concourse/releasescripts/concourse-release-scripts/0.1.0/concourse-release-scripts-0.1.0.jar ########################################################### # JAVA diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 0c8ec20d30e4..3671d4f21db1 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -317,8 +317,51 @@ jobs: username: concourse-ci - put: repo-status-jdk15-build params: { state: "success", commit: "git-repo" } +- name: stage-milestone + serial: true + plan: + - get: spring-framework-ci-image + - get: git-repo + trigger: false + - task: stage + image: spring-framework-ci-image + file: git-repo/ci/tasks/stage-version.yml + params: + RELEASE_TYPE: M + GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key)) + GRADLE_ENTERPRISE_CACHE_USERNAME: ((gradle_enterprise_cache_user.username)) + GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password)) + - put: artifactory-repo + params: + <<: *artifactory-params + repo: libs-staging-local + - put: git-repo + params: + repository: stage-git-repo +- name: promote-milestone + serial: true + plan: + - get: spring-framework-ci-image + - get: git-repo + trigger: false + - get: artifactory-repo + trigger: false + passed: [stage-milestone] + params: + download_artifacts: false + save_build_info: true + - task: promote + image: spring-framework-ci-image + file: git-repo/ci/tasks/promote-version.yml + params: + RELEASE_TYPE: M + ARTIFACTORY_SERVER: ((artifactory-server)) + ARTIFACTORY_USERNAME: ((artifactory-username)) + ARTIFACTORY_PASSWORD: ((artifactory-password)) groups: - name: "Build" jobs: ["build", "jdk11-build", "jdk14-build", "jdk15-build"] +- name: "Release" + jobs: ["stage-milestone", "promote-milestone"] - name: "CI Images" jobs: ["build-spring-framework-ci-images"] diff --git a/ci/scripts/promote-version.sh b/ci/scripts/promote-version.sh new file mode 100755 index 000000000000..c27ecb0bc6ce --- /dev/null +++ b/ci/scripts/promote-version.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +source $(dirname $0)/common.sh + +version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' ) +export BUILD_INFO_LOCATION=$(pwd)/artifactory-repo/build-info.json + +java -jar /opt/concourse-release-scripts.jar promote $RELEASE_TYPE $BUILD_INFO_LOCATION > /dev/null || { exit 1; } + +java -jar /opt/concourse-release-scripts.jar distribute $RELEASE_TYPE $BUILD_INFO_LOCATION > /dev/null || { exit 1; } + +echo "Promotion complete" +echo $version > version/version diff --git a/ci/scripts/stage-version.sh b/ci/scripts/stage-version.sh new file mode 100755 index 000000000000..0b285de014bf --- /dev/null +++ b/ci/scripts/stage-version.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -e + +source $(dirname $0)/common.sh +repository=$(pwd)/distribution-repository + +pushd git-repo > /dev/null +git fetch --tags --all > /dev/null +popd > /dev/null + +git clone git-repo stage-git-repo > /dev/null + +pushd stage-git-repo > /dev/null + +snapshotVersion=$( awk -F '=' '$1 == "version" { print $2 }' gradle.properties ) +if [[ $RELEASE_TYPE = "M" ]]; then + stageVersion=$( get_next_milestone_release $snapshotVersion) + nextVersion=$snapshotVersion +elif [[ $RELEASE_TYPE = "RC" ]]; then + stageVersion=$( get_next_rc_release $snapshotVersion) + nextVersion=$snapshotVersion +elif [[ $RELEASE_TYPE = "RELEASE" ]]; then + stageVersion=$( get_next_release $snapshotVersion) + nextVersion=$( bump_version_number $snapshotVersion) +else + echo "Unknown release type $RELEASE_TYPE" >&2; exit 1; +fi + +echo "Staging $stageVersion (next version will be $nextVersion)" +sed -i "s/version=$snapshotVersion/version=$stageVersion/" gradle.properties + +git config user.name "Spring Buildmaster" > /dev/null +git config user.email "buildmaster@springframework.org" > /dev/null +git add gradle.properties > /dev/null +git commit -m"Release v$stageVersion" > /dev/null +git tag -a "v$stageVersion" -m"Release v$stageVersion" > /dev/null + +./gradlew --no-daemon --max-workers=4 -PdeploymentRepository=${repository} build publishAllPublicationsToDeploymentRepository + +git reset --hard HEAD^ > /dev/null +if [[ $nextVersion != $snapshotVersion ]]; then + echo "Setting next development version (v$nextVersion)" + sed -i "s/version=$snapshotVersion/version=$nextVersion/" gradle.properties + git add gradle.properties > /dev/null + git commit -m"Next development version (v$nextVersion)" > /dev/null +fi; + +echo "Staging Complete" + +popd > /dev/null diff --git a/ci/tasks/promote-version.yml b/ci/tasks/promote-version.yml new file mode 100644 index 000000000000..2da899a0ebe0 --- /dev/null +++ b/ci/tasks/promote-version.yml @@ -0,0 +1,18 @@ +--- +platform: linux +inputs: +- name: git-repo +- name: artifactory-repo +outputs: +- name: version +params: + RELEASE_TYPE: + ARTIFACTORY_SERVER: + ARTIFACTORY_USERNAME: + ARTIFACTORY_PASSWORD: + BINTRAY_SUBJECT: + BINTRAY_REPO: + BINTRAY_USERNAME: + BINTRAY_API_KEY: +run: + path: git-repo/ci/scripts/promote-version.sh diff --git a/ci/tasks/stage-version.yml b/ci/tasks/stage-version.yml new file mode 100644 index 000000000000..ded11483a76b --- /dev/null +++ b/ci/tasks/stage-version.yml @@ -0,0 +1,17 @@ +--- +platform: linux +inputs: +- name: git-repo +outputs: +- name: stage-git-repo +- name: distribution-repository +params: + RELEASE_TYPE: + CI: true + GRADLE_ENTERPRISE_CACHE_USERNAME: + GRADLE_ENTERPRISE_CACHE_PASSWORD: + GRADLE_ENTERPRISE_URL: https://ge.spring.io +caches: +- path: gradle +run: + path: git-repo/ci/scripts/stage-version.sh