Skip to content

Commit daf94ed

Browse files
committed
#815 - Make releases from Concourse.
Related to #814.
1 parent 82efbfb commit daf94ed

7 files changed

+323
-6
lines changed

ci/README.adoc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,28 @@ WARNING: Do NOT check this file into source control! If you'll check, `credentia
2727
With this in place, run the following `fly` commands to create pipelines:
2828

2929
----
30-
% fly -t spring-data sp -p spring-hateoas -c ci/pipeline-template.yml -l credentials.yml -v branch=master
30+
% fly -t spring-data sp -p spring-hateoas -c ci/pipeline-template.yml -l credentials.yml -v branch=master -v release-branch=release
3131
----
3232

3333
With this pipeline in place, you can now activate and expose it:
3434

3535
----
3636
% fly -t spring-data unpause-pipeline -p spring-hateoas
3737
% fly -t spring-data expose-pipeline -p spring-hateoas
38-
----
38+
----
39+
40+
=== Making a release
41+
42+
1. Create a new release (on the main branch).
43+
----
44+
% ci/create-release.sh <release version> <next snapshot version>
45+
----
46+
47+
2. With the release tagged, push the tagged version to the release branch.
48+
----
49+
% git checkout -b release
50+
% git reset --hard <tag>
51+
% git push -f origin release
52+
----
53+
54+
NOTE: You can chain the previous set of commands together using `&&`.

ci/create-release.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
RELEASE=$1
6+
SNAPSHOT=$2
7+
8+
# Bump up the version in pom.xml to the desired version and commit the change
9+
./mvnw versions:set -DnewVersion=$RELEASE -DgenerateBackupPoms=false
10+
git add .
11+
git commit --message "Releasing Spring HATEOAS v$RELEASE"
12+
13+
# Tag the release
14+
git tag -s v$RELEASE -m "v$RELEASE"
15+
16+
# Bump up the version in pom.xml to the next snapshot
17+
./mvnw versions:set -DnewVersion=$SNAPSHOT -DgenerateBackupPoms=false
18+
git add .
19+
git commit --message "Continue development on v$SNAPSHOT"
20+
21+

ci/pipeline-template.yml

Lines changed: 174 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ resources:
6363
repo: spring-projects/spring-hateoas
6464
base: ((branch))
6565

66+
- name: spring-hateoas-release
67+
type: git
68+
source:
69+
uri: https://github.com/spring-projects/spring-hateoas.git
70+
branch: ((release-branch))
71+
6672
- name: spring-hateoas-status
6773
type: github-status
6874
source:
@@ -85,6 +91,11 @@ groups:
8591
- name: pull-requests
8692
jobs:
8793
- spring-hateoas-pull-requests
94+
- name: release
95+
jobs:
96+
- release-to-artifactory
97+
# - promote-to-bintray
98+
# - sync-to-maven-central
8899

89100
jobs:
90101
- name: Test - JDK 8
@@ -98,7 +109,7 @@ jobs:
98109
- task: test
99110
file: spring-hateoas-github/ci/test.yml
100111
params: { PROFILE: "non-existent" }
101-
<<: *slack-failure
112+
<<: *slack-test-failure
102113

103114
- name: Test - JDK 11
104115
serial: true
@@ -112,7 +123,7 @@ jobs:
112123
image: openjdk:11-jdk
113124
file: spring-hateoas-github/ci/test.yml
114125
params: { PROFILE: "non-existant" }
115-
<<: *slack-failure
126+
<<: *slack-test-failure
116127

117128
- name: Test - JDK 13
118129
serial: true
@@ -126,7 +137,7 @@ jobs:
126137
image: openjdk:13-jdk
127138
file: spring-hateoas-github/ci/test.yml
128139
params: { PROFILE: "non-existant" }
129-
<<: *slack-failure
140+
<<: *slack-test-failure
130141

131142
- name: Build
132143
serial: true
@@ -242,7 +253,166 @@ jobs:
242253
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
243254
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
244255

245-
slack-failure: &slack-failure
256+
- name: release-to-artifactory
257+
serial: true
258+
public: true
259+
plan:
260+
- get: spring-hateoas-github
261+
resource: spring-hateoas-release
262+
trigger: true
263+
- put: spring-hateoas-status
264+
params:
265+
commit: spring-hateoas-release
266+
state: pending
267+
- task: build
268+
file: spring-hateoas-github/ci/build.yml
269+
- put: spring-hateoas-artifactory
270+
params:
271+
build_number: ${BUILD_NAME}
272+
build_uri: ${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}
273+
repo: libs-milestone-local
274+
folder: spring-hateoas-artifactory
275+
artifact_set:
276+
- include:
277+
- "/**"
278+
properties:
279+
zip.deployed: false
280+
zip.displayname: "Spring HATEOAS"
281+
zip.name: "spring-hateoas"
282+
zip.type: "docs"
283+
on_failure:
284+
aggregate:
285+
- put: spring-hateoas-status
286+
params:
287+
commit: spring-hateoas-github
288+
state: failure
289+
- put: slack
290+
params:
291+
attachments:
292+
- color: danger
293+
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
294+
text: "Releasing to artifactory has failed"
295+
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
296+
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
297+
on_success:
298+
aggregate:
299+
- put: spring-hateoas-status
300+
params:
301+
commit: spring-hateoas-github
302+
state: success
303+
- put: slack
304+
params:
305+
attachments:
306+
- color: good
307+
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
308+
text: "Releasing to artifactory has succeeded!"
309+
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
310+
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
311+
312+
#- name: promote-to-bintray
313+
# serial: true
314+
# plan:
315+
# - get: spring-hateoas-github
316+
# resource: spring-hateoas-release
317+
# - get: spring-hateoas-artifactory
318+
# trigger: true
319+
# passed: [release-to-artifactory]
320+
# params:
321+
# save_build_info: true
322+
# - task: promote-to-bintray
323+
# file: spring-hateoas-github/ci/promote-to-bintray.yml
324+
# params:
325+
# ARTIFACTORY_USERNAME: ((artifactory-username))
326+
# ARTIFACTORY_PASSWORD: ((artifactory-password))
327+
# on_failure:
328+
# aggregate:
329+
# - put: spring-hateoas-status
330+
# params:
331+
# commit: spring-hateoas-github
332+
# state: failure
333+
# - put: slack
334+
# params:
335+
# attachments:
336+
# - color: danger
337+
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
338+
# text: "Promoting to bintray has failed"
339+
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
340+
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
341+
# on_success:
342+
# aggregate:
343+
# - put: spring-hateoas-status
344+
# params:
345+
# commit: spring-hateoas-github
346+
# state: success
347+
# - put: slack
348+
# params:
349+
# attachments:
350+
# - color: good
351+
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
352+
# text: "Promoting to bintray has succeeded!"
353+
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
354+
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
355+
356+
#- name: sync-to-maven-central
357+
# serial: true
358+
# plan:
359+
# - get: spring-hateoas-github
360+
# resource: spring-hateoas-release
361+
# - get: spring-hateoas-artifactory
362+
# trigger: true
363+
# passed: [promote-to-bintray]
364+
# params:
365+
# save_build_info: true
366+
# - task: sync-to-maven-central
367+
# file: spring-hateoas-github/ci/sync-to-maven-central.yml
368+
# params:
369+
# BINTRAY_USERNAME: ((bintray-username))
370+
# BINTRAY_API_KEY: ((bintray-api-key))
371+
# SONATYPE_USER_TOKEN: ((sonatype-user-token))
372+
# SONATYPE_PASSWORD_TOKEN: ((sonatype-user-token-password))
373+
# ARTIFACTORY_USERNAME: ((artifactory-username))
374+
# ARTIFACTORY_PASSWORD: ((artifactory-password))
375+
# on_failure:
376+
# aggregate:
377+
# - put: spring-hateoas-status
378+
# params:
379+
# commit: spring-hateoas-github
380+
# state: failure
381+
# - put: slack
382+
# params:
383+
# attachments:
384+
# - color: danger
385+
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
386+
# text: "Syncing to maven central has failed"
387+
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
388+
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
389+
# on_success:
390+
# aggregate:
391+
# - put: spring-hateoas-status
392+
# params:
393+
# commit: spring-hateoas-github
394+
# state: success
395+
# - put: slack
396+
# params:
397+
# attachments:
398+
# - color: good
399+
# fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
400+
# text: "Syncing to maven central has succeeded!"
401+
# title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
402+
# title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
403+
#
404+
slack-test-success: &slack-test-success
405+
on_success:
406+
put: slack
407+
params:
408+
attachments:
409+
- color: good
410+
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
411+
text: "Test has succeeded"
412+
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
413+
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
414+
415+
slack-test-failure: &slack-test-failure
246416
on_failure:
247417
put: slack
248418
params:

ci/promote-to-bintray.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
set -e -u
4+
5+
apt-get update
6+
apt-get install -y jq
7+
8+
buildName=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.name' )
9+
buildNumber=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.number' )
10+
groupId=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
11+
version=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
12+
targetRepo="libs-release-local"
13+
14+
echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}"
15+
16+
curl \
17+
-s \
18+
--connect-timeout 240 \
19+
--max-time 2700 \
20+
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
21+
-H "Content-type:application/json" \
22+
-d "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"spring-distributions\", \"async\":\"true\"}" \
23+
-f \
24+
-X \
25+
POST "https://repo.spring.io/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to distribute" >&2; exit 1; }
26+
27+
echo "Waiting for artifacts to be published"
28+
29+
ARTIFACTS_PUBLISHED=false
30+
WAIT_TIME=10
31+
COUNTER=0
32+
33+
while [ $ARTIFACTS_PUBLISHED == "false" ] && [ $COUNTER -lt 120 ]; do
34+
35+
result=$( curl -s https://api.bintray.com/packages/spring/jars/"${groupId}" )
36+
versions=$( echo "$result" | jq -r '.versions' )
37+
exists=$( echo "$versions" | grep "$version" -o || true )
38+
39+
if [ "$exists" = "$version" ]; then
40+
ARTIFACTS_PUBLISHED=true
41+
fi
42+
43+
COUNTER=$(( COUNTER + 1 ))
44+
sleep $WAIT_TIME
45+
46+
done

ci/promote-to-bintray.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
platform: linux
3+
4+
image_resource:
5+
type: docker-image
6+
source:
7+
repository: openjdk
8+
tag: 8-jdk
9+
10+
inputs:
11+
- name: spring-hateoas-artifactory
12+
- name: spring-hateoas-github
13+
14+
run:
15+
path: spring-hateoas-github/ci/promote-to-bintray.sh
16+
17+
params:
18+
ARTIFACTORY_USERNAME:
19+
ARTIFACTORY_PASSWORD:

ci/sync-to-maven-central.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -e -u
4+
5+
apt-get update
6+
apt-get install -y jq
7+
8+
buildName=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.name' )
9+
buildNumber=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.number' )
10+
groupId=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
11+
version=$( cat spring-hateoas-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
12+
13+
echo "Syncing ${buildName}/${buildNumber} to Maven Central"
14+
curl \
15+
-s \
16+
--connect-timeout 240 \
17+
--max-time 2700 \
18+
-u ${BINTRAY_USERNAME}:${BINTRAY_API_KEY} \
19+
-H "Content-Type: application/json" -d "{ \"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \
20+
-f \
21+
-X \
22+
POST "https://api.bintray.com/maven_central_sync/spring/jars/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; }
23+
24+
echo "Sync complete"

ci/sync-to-maven-central.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
platform: linux
3+
4+
image_resource:
5+
type: docker-image
6+
source:
7+
repository: openjdk
8+
tag: 8-jdk
9+
10+
inputs:
11+
- name: spring-hateoas-artifactory
12+
- name: spring-hateoas-github
13+
14+
run:
15+
path: spring-hateoas-github/ci/sync-to-maven-central.sh
16+
17+
params:
18+
BINTRAY_USERNAME:
19+
BINTRAY_API_KEY:
20+
SONATYPE_USER_TOKEN:
21+
SONATYPE_PASSWORD_TOKEN:

0 commit comments

Comments
 (0)