diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 5823c364d1..3f36bf03f7 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -27,6 +27,11 @@ resources: password: ((github-password)) branch: ((branch)) ignore_paths: ["ci/images/*"] +- name: release-notes-repo + type: git + source: + uri: https://github.com/mbhave/release-notes-generator + branch: master - name: git-pull-request type: pull-request source: @@ -307,6 +312,7 @@ jobs: - get: spring-boot-ci-image - get: git-repo trigger: false + - get: release-notes-repo - task: stage image: spring-boot-ci-image file: git-repo/ci/tasks/stage.yml @@ -319,6 +325,14 @@ jobs: - put: git-repo params: repository: stage-git-repo + - task: publish-release-notes + image: spring-boot-ci-image + file: git-repo/ci/tasks/publish-release-notes.yml + params: + GITHUB_ORGANIZATION: spring-projects + GITHUB_REPO: spring-boot + GITHUB_USERNAME: ((github-username)) + GITHUB_PASSWORD: ((github-release-notes-access-token)) - name: stage-rc serial: true plan: @@ -337,6 +351,14 @@ jobs: - put: git-repo params: repository: stage-git-repo + - task: publish-release-notes + image: spring-boot-ci-image + file: git-repo/ci/tasks/publish-release-notes.yml + params: + GITHUB_ORGANIZATION: spring-projects + GITHUB_REPO: spring-boot + GITHUB_USERNAME: ((github-username)) + GITHUB_PASSWORD: ((github-release-notes-access-token)) - name: stage-release serial: true plan: @@ -355,6 +377,14 @@ jobs: - put: git-repo params: repository: stage-git-repo + - task: publish-release-notes + image: spring-boot-ci-image + file: git-repo/ci/tasks/publish-release-notes.yml + params: + GITHUB_ORGANIZATION: spring-projects + GITHUB_REPO: spring-boot + GITHUB_USERNAME: ((github-username)) + GITHUB_PASSWORD: ((github-release-notes-access-token)) - name: promote-milestone serial: true plan: diff --git a/ci/scripts/publish-release-notes.sh b/ci/scripts/publish-release-notes.sh new file mode 100644 index 0000000000..0f1ded7562 --- /dev/null +++ b/ci/scripts/publish-release-notes.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +source $(dirname $0)/common.sh + +latest=$( curl -s "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/releases/latest" -u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} ) +id=$( echo $latest | jq -r '.id' ) + +milestone=$( cat version/stageVersion ) +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') + +pushd release-notes-repo > /dev/null +run_maven clean install +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 +popd > /dev/null + + +body=$( sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g' release-notes-repo/release-notes.md ) + +curl \ + -s \ + -u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \ + -H "Content-type:application/json" \ + -d "{\"body\": \"${body}\"}" \ + -f \ + -X \ + PATCH "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/releases/${id}" > /dev/null || { echo "Failed to publish" >&2; exit 1; } diff --git a/ci/scripts/stage.sh b/ci/scripts/stage.sh index b8ecc4f625..c529bcc6e0 100755 --- a/ci/scripts/stage.sh +++ b/ci/scripts/stage.sh @@ -51,3 +51,4 @@ fi; echo "DONE" popd > /dev/null +echo $stageVersion > version/stageVersion diff --git a/ci/tasks/publish-release-notes.yml b/ci/tasks/publish-release-notes.yml new file mode 100755 index 0000000000..64b286468f --- /dev/null +++ b/ci/tasks/publish-release-notes.yml @@ -0,0 +1,13 @@ +--- +platform: linux +inputs: +- name: git-repo +- name: release-notes-repo +- name: version +params: + GITHUB_ORGANIZATION: + GITHUB_REPO: + GITHUB_USERNAME: + GITHUB_PASSWORD: +run: + path: git-repo/ci/scripts/publish-release-notes.sh diff --git a/ci/tasks/stage.yml b/ci/tasks/stage.yml index f486313ae9..f05f6d176a 100644 --- a/ci/tasks/stage.yml +++ b/ci/tasks/stage.yml @@ -5,6 +5,7 @@ inputs: outputs: - name: stage-git-repo - name: distribution-repository +- name: version params: RELEASE_TYPE: caches: