#815 - Make releases from Concourse.

Related to #814.
This commit is contained in:
Greg Turnquist
2019-02-15 08:41:46 -06:00
parent 82efbfb6aa
commit daf94ed7b9
7 changed files with 323 additions and 6 deletions

View File

@@ -27,7 +27,7 @@ WARNING: Do NOT check this file into source control! If you'll check, `credentia
With this in place, run the following `fly` commands to create pipelines:
----
% fly -t spring-data sp -p spring-hateoas -c ci/pipeline-template.yml -l credentials.yml -v branch=master
% fly -t spring-data sp -p spring-hateoas -c ci/pipeline-template.yml -l credentials.yml -v branch=master -v release-branch=release
----
With this pipeline in place, you can now activate and expose it:
@@ -35,4 +35,20 @@ With this pipeline in place, you can now activate and expose it:
----
% fly -t spring-data unpause-pipeline -p spring-hateoas
% fly -t spring-data expose-pipeline -p spring-hateoas
----
----
=== Making a release
1. Create a new release (on the main branch).
----
% ci/create-release.sh <release version> <next snapshot version>
----
2. With the release tagged, push the tagged version to the release branch.
----
% git checkout -b release
% git reset --hard <tag>
% git push -f origin release
----
NOTE: You can chain the previous set of commands together using `&&`.

21
ci/create-release.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
RELEASE=$1
SNAPSHOT=$2
# Bump up the version in pom.xml to the desired version and commit the change
./mvnw versions:set -DnewVersion=$RELEASE -DgenerateBackupPoms=false
git add .
git commit --message "Releasing Spring HATEOAS v$RELEASE"
# Tag the release
git tag -s v$RELEASE -m "v$RELEASE"
# Bump up the version in pom.xml to the next snapshot
./mvnw versions:set -DnewVersion=$SNAPSHOT -DgenerateBackupPoms=false
git add .
git commit --message "Continue development on v$SNAPSHOT"

View File

@@ -63,6 +63,12 @@ resources:
repo: spring-projects/spring-hateoas
base: ((branch))
- name: spring-hateoas-release
type: git
source:
uri: https://github.com/spring-projects/spring-hateoas.git
branch: ((release-branch))
- name: spring-hateoas-status
type: github-status
source:
@@ -85,6 +91,11 @@ groups:
- name: pull-requests
jobs:
- spring-hateoas-pull-requests
- name: release
jobs:
- release-to-artifactory
# - promote-to-bintray
# - sync-to-maven-central
jobs:
- name: Test - JDK 8
@@ -98,7 +109,7 @@ jobs:
- task: test
file: spring-hateoas-github/ci/test.yml
params: { PROFILE: "non-existent" }
<<: *slack-failure
<<: *slack-test-failure
- name: Test - JDK 11
serial: true
@@ -112,7 +123,7 @@ jobs:
image: openjdk:11-jdk
file: spring-hateoas-github/ci/test.yml
params: { PROFILE: "non-existant" }
<<: *slack-failure
<<: *slack-test-failure
- name: Test - JDK 13
serial: true
@@ -126,7 +137,7 @@ jobs:
image: openjdk:13-jdk
file: spring-hateoas-github/ci/test.yml
params: { PROFILE: "non-existant" }
<<: *slack-failure
<<: *slack-test-failure
- name: Build
serial: true
@@ -242,7 +253,166 @@ jobs:
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
slack-failure: &slack-failure
- name: release-to-artifactory
serial: true
public: true
plan:
- get: spring-hateoas-github
resource: spring-hateoas-release
trigger: true
- put: spring-hateoas-status
params:
commit: spring-hateoas-release
state: pending
- task: build
file: spring-hateoas-github/ci/build.yml
- put: spring-hateoas-artifactory
params:
build_number: ${BUILD_NAME}
build_uri: ${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}
repo: libs-milestone-local
folder: spring-hateoas-artifactory
artifact_set:
- include:
- "/**"
properties:
zip.deployed: false
zip.displayname: "Spring HATEOAS"
zip.name: "spring-hateoas"
zip.type: "docs"
on_failure:
aggregate:
- put: spring-hateoas-status
params:
commit: spring-hateoas-github
state: failure
- put: slack
params:
attachments:
- color: danger
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
text: "Releasing to artifactory has failed"
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
on_success:
aggregate:
- put: spring-hateoas-status
params:
commit: spring-hateoas-github
state: success
- put: slack
params:
attachments:
- color: good
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
text: "Releasing to artifactory has succeeded!"
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
#- name: promote-to-bintray
# serial: true
# plan:
# - get: spring-hateoas-github
# resource: spring-hateoas-release
# - get: spring-hateoas-artifactory
# trigger: true
# passed: [release-to-artifactory]
# params:
# save_build_info: true
# - task: promote-to-bintray
# file: spring-hateoas-github/ci/promote-to-bintray.yml
# params:
# ARTIFACTORY_USERNAME: ((artifactory-username))
# ARTIFACTORY_PASSWORD: ((artifactory-password))
# on_failure:
# aggregate:
# - put: spring-hateoas-status
# params:
# commit: spring-hateoas-github
# state: failure
# - put: slack
# params:
# attachments:
# - color: danger
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
# text: "Promoting to bintray has failed"
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
# on_success:
# aggregate:
# - put: spring-hateoas-status
# params:
# commit: spring-hateoas-github
# state: success
# - put: slack
# params:
# attachments:
# - color: good
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
# text: "Promoting to bintray has succeeded!"
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
#- name: sync-to-maven-central
# serial: true
# plan:
# - get: spring-hateoas-github
# resource: spring-hateoas-release
# - get: spring-hateoas-artifactory
# trigger: true
# passed: [promote-to-bintray]
# params:
# save_build_info: true
# - task: sync-to-maven-central
# file: spring-hateoas-github/ci/sync-to-maven-central.yml
# params:
# BINTRAY_USERNAME: ((bintray-username))
# BINTRAY_API_KEY: ((bintray-api-key))
# SONATYPE_USER_TOKEN: ((sonatype-user-token))
# SONATYPE_PASSWORD_TOKEN: ((sonatype-user-token-password))
# ARTIFACTORY_USERNAME: ((artifactory-username))
# ARTIFACTORY_PASSWORD: ((artifactory-password))
# on_failure:
# aggregate:
# - put: spring-hateoas-status
# params:
# commit: spring-hateoas-github
# state: failure
# - put: slack
# params:
# attachments:
# - color: danger
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
# text: "Syncing to maven central has failed"
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
# on_success:
# aggregate:
# - put: spring-hateoas-status
# params:
# commit: spring-hateoas-github
# state: success
# - put: slack
# params:
# attachments:
# - color: good
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
# text: "Syncing to maven central has succeeded!"
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
#
slack-test-success: &slack-test-success
on_success:
put: slack
params:
attachments:
- color: good
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
text: "Test has succeeded"
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
slack-test-failure: &slack-test-failure
on_failure:
put: slack
params:

46
ci/promote-to-bintray.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
set -e -u
apt-get update
apt-get install -y jq
buildName=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.name' )
buildNumber=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.number' )
groupId=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
version=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
targetRepo="libs-release-local"
echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
-H "Content-type:application/json" \
-d "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"spring-distributions\", \"async\":\"true\"}" \
-f \
-X \
POST "https://repo.spring.io/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to distribute" >&2; exit 1; }
echo "Waiting for artifacts to be published"
ARTIFACTS_PUBLISHED=false
WAIT_TIME=10
COUNTER=0
while [ $ARTIFACTS_PUBLISHED == "false" ] && [ $COUNTER -lt 120 ]; do
result=$( curl -s https://api.bintray.com/packages/spring/jars/"${groupId}" )
versions=$( echo "$result" | jq -r '.versions' )
exists=$( echo "$versions" | grep "$version" -o || true )
if [ "$exists" = "$version" ]; then
ARTIFACTS_PUBLISHED=true
fi
COUNTER=$(( COUNTER + 1 ))
sleep $WAIT_TIME
done

19
ci/promote-to-bintray.yml Normal file
View File

@@ -0,0 +1,19 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: openjdk
tag: 8-jdk
inputs:
- name: spring-hateoas-artifactory
- name: spring-hateoas-github
run:
path: spring-hateoas-github/ci/promote-to-bintray.sh
params:
ARTIFACTORY_USERNAME:
ARTIFACTORY_PASSWORD:

24
ci/sync-to-maven-central.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -e -u
apt-get update
apt-get install -y jq
buildName=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.name' )
buildNumber=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.number' )
groupId=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
version=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
echo "Syncing ${buildName}/${buildNumber} to Maven Central"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${BINTRAY_USERNAME}:${BINTRAY_API_KEY} \
-H "Content-Type: application/json" -d "{ \"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \
-f \
-X \
POST "https://api.bintray.com/maven_central_sync/spring/jars/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; }
echo "Sync complete"

View File

@@ -0,0 +1,21 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: openjdk
tag: 8-jdk
inputs:
- name: spring-hateoas-artifactory
- name: spring-hateoas-github
run:
path: spring-hateoas-github/ci/sync-to-maven-central.sh
params:
BINTRAY_USERNAME:
BINTRAY_API_KEY:
SONATYPE_USER_TOKEN:
SONATYPE_PASSWORD_TOKEN: