Skip to content

Commit 7d04c51

Browse files
committed
Automate creation of releases notes on GitHub
Closes gh-12552
1 parent 63d276d commit 7d04c51

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

ci/pipeline.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ resources:
2727
password: ((github-password))
2828
branch: ((branch))
2929
ignore_paths: ["ci/images/*"]
30+
- name: release-notes-repo
31+
type: git
32+
source:
33+
uri: https://github.com/mbhave/release-notes-generator
34+
branch: master
3035
- name: git-pull-request
3136
type: pull-request
3237
source:
@@ -307,6 +312,7 @@ jobs:
307312
- get: spring-boot-ci-image
308313
- get: git-repo
309314
trigger: false
315+
- get: release-notes-repo
310316
- task: stage
311317
image: spring-boot-ci-image
312318
file: git-repo/ci/tasks/stage.yml
@@ -319,6 +325,14 @@ jobs:
319325
- put: git-repo
320326
params:
321327
repository: stage-git-repo
328+
- task: publish-release-notes
329+
image: spring-boot-ci-image
330+
file: git-repo/ci/tasks/publish-release-notes.yml
331+
params:
332+
GITHUB_ORGANIZATION: spring-projects
333+
GITHUB_REPO: spring-boot
334+
GITHUB_USERNAME: ((github-username))
335+
GITHUB_PASSWORD: ((github-release-notes-access-token))
322336
- name: stage-rc
323337
serial: true
324338
plan:
@@ -337,6 +351,14 @@ jobs:
337351
- put: git-repo
338352
params:
339353
repository: stage-git-repo
354+
- task: publish-release-notes
355+
image: spring-boot-ci-image
356+
file: git-repo/ci/tasks/publish-release-notes.yml
357+
params:
358+
GITHUB_ORGANIZATION: spring-projects
359+
GITHUB_REPO: spring-boot
360+
GITHUB_USERNAME: ((github-username))
361+
GITHUB_PASSWORD: ((github-release-notes-access-token))
340362
- name: stage-release
341363
serial: true
342364
plan:
@@ -355,6 +377,14 @@ jobs:
355377
- put: git-repo
356378
params:
357379
repository: stage-git-repo
380+
- task: publish-release-notes
381+
image: spring-boot-ci-image
382+
file: git-repo/ci/tasks/publish-release-notes.yml
383+
params:
384+
GITHUB_ORGANIZATION: spring-projects
385+
GITHUB_REPO: spring-boot
386+
GITHUB_USERNAME: ((github-username))
387+
GITHUB_PASSWORD: ((github-release-notes-access-token))
358388
- name: promote-milestone
359389
serial: true
360390
plan:

ci/scripts/publish-release-notes.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/common.sh
5+
6+
latest=$( curl -s "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/releases/latest" -u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} )
7+
id=$( echo $latest | jq -r '.id' )
8+
9+
milestone=$( cat version/stageVersion )
10+
milestone_number=$( curl -s "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones" -u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} | jq -r --arg MILESTONE "${milestone}" '.[] | select(.title == $MILESTONE) | .number')
11+
12+
pushd release-notes-repo > /dev/null
13+
run_maven clean install
14+
java -jar -Dreleasenotes.github.organization=${GITHUB_ORGANIZATION} -Dreleasenotes.github.name=${GITHUB_REPO} target/github-release-notes-generator-0.0.1-SNAPSHOT.jar "${milestone_number}" release-notes.md
15+
popd > /dev/null
16+
17+
18+
body=$( sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' release-notes-repo/release-notes.md )
19+
20+
curl \
21+
-s \
22+
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
23+
-H "Content-type:application/json" \
24+
-d "{\"body\": \"${body}\"}" \
25+
-f \
26+
-X \
27+
PATCH "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/releases/${id}" > /dev/null || { echo "Failed to publish" >&2; exit 1; }

ci/scripts/stage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ fi;
5151
echo "DONE"
5252

5353
popd > /dev/null
54+
echo $stageVersion > version/stageVersion

ci/tasks/publish-release-notes.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
platform: linux
3+
inputs:
4+
- name: git-repo
5+
- name: release-notes-repo
6+
- name: version
7+
params:
8+
GITHUB_ORGANIZATION:
9+
GITHUB_REPO:
10+
GITHUB_USERNAME:
11+
GITHUB_PASSWORD:
12+
run:
13+
path: git-repo/ci/scripts/publish-release-notes.sh

ci/tasks/stage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ inputs:
55
outputs:
66
- name: stage-git-repo
77
- name: distribution-repository
8+
- name: version
89
params:
910
RELEASE_TYPE:
1011
caches:

0 commit comments

Comments
 (0)