CI: Adjustments to the release job (#4129)

Extracted the logic to pull the latest release notes, out of
`bin/create-release-tag` into `bin/_release.sh` so that it can be reused
in the `release.yml` workflow, which needs to use that inside
`gh_release` when creating the github release in order to have prettier
markup release notes instead of a plaintext message pulled out of the tag
message.
The new extracted function also receives an optional argument with the
name of the file to put the release notes into, because the `body_path`
parameter in `softprops/action-gh-release` doesn't work with dynamic
vars.

Finally, now the `website_publish` job will only launch until the `gh_release`
has succeeded.
This commit is contained in:
Alejandro Pedraza 2020-03-05 09:03:30 -05:00 committed by GitHub
parent 72fc94b03c
commit 578a2d1960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 12 deletions

View File

@ -230,7 +230,9 @@ jobs:
- name: Set environment variables from scripts - name: Set environment variables from scripts
run: | run: |
. bin/_tag.sh . bin/_tag.sh
. bin/_release.sh
echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag) echo ::set-env name=TAG::$(CI_FORCE_CLEAN=1 bin/root-tag)
extract_release_notes NOTES.md
- name: Pull CLI binaries - name: Pull CLI binaries
run : bin/docker-pull-binaries $TAG run : bin/docker-pull-binaries $TAG
- name: Create release - name: Create release
@ -242,6 +244,7 @@ jobs:
with: with:
draft: false draft: false
prelease: false prelease: false
body_path: NOTES.md
files: | files: |
./target/release/linkerd2-cli-*-darwin ./target/release/linkerd2-cli-*-darwin
./target/release/linkerd2-cli-*-darwin.sha256 ./target/release/linkerd2-cli-*-darwin.sha256
@ -253,7 +256,7 @@ jobs:
name: Linkerd website publish name: Linkerd website publish
if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge') if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge')
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: [kind_integration_tests, cloud_integration_tests] needs: [gh_release]
steps: steps:
- name: Create linkerd/website repository dispatch event - name: Create linkerd/website repository dispatch event
# peter-evans/repository-dispatch@v1 # peter-evans/repository-dispatch@v1

25
bin/_release.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -eu
extract_release_notes() {
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
rootdir=$( cd "$bindir"/.. && pwd )
if [ $# -eq 0 ]
then
# Make temporary file to save the release commit message into.
tmp=$(mktemp -t release-commit-message.XXX.txt)
else
tmp="$rootdir/$1"
fi
# Save commit message into temporary file.
#
# Match each occurence of the regex and increment `n` by 1. While n == 1
# (which is true only for the first section) print that line of `CHANGES.md`.
# This ends up being the first section of release changes.
awk '/^## (edge|stable)-[0-9]+\.[0-9]+\.[0-9]+/{n++} n==1' "$rootdir"/CHANGES.md > "$tmp"
echo "$tmp"
}

View File

@ -27,17 +27,9 @@ fi
# todo: Verify the tag version increment. # todo: Verify the tag version increment.
rootdir=$( cd "${0%/*}"/.. && pwd ) bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
# shellcheck source=bin/_release.sh
# Make temporary file to save the release commit message into. tmp=$(. "$bindir"/_release.sh; extract_release_notes)
tmp=$(mktemp -t release-commit-message.XXX.txt)
# Save commit message into temporary file.
#
# Match each occurence of the regex and increment `n` by 1. While n == 1
# (which is true only for the first section) print that line of `CHANGES.md`.
# This ends up being the first section of release changes.
awk '/^## (edge|stable)-[0-9]+\.[0-9]+\.[0-9]+/{n++} n==1' "$rootdir"/CHANGES.md > "$tmp"
# Create an unsigned tag with the commit message. # Create an unsigned tag with the commit message.
git tag -s -F "$tmp" "$tag" git tag -s -F "$tmp" "$tag"