Rework release workflow (#1609)

Change the release workflow and jobs to ensure more of it is always
exercised for any change and only the actual publishing of the release
is the only part that is limited to be run when tagged.

Additionally try to enable caching and save the generated notes as an
artifact in case the final step fails.
This commit is contained in:
Darragh Bailey
2022-09-28 14:06:53 +01:00
committed by GitHub
parent f111842dbe
commit 14a8889e33

View File

@@ -2,13 +2,17 @@ name: release
on: on:
push: push:
branches:
- '**'
tags: tags:
- '*.*.*' - '*.*.*'
jobs: jobs:
release: release-notes:
name: Create Release name: Generate Release Notes
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
release_branch: ${{ steps.prep.outputs.release_branch }}
steps: steps:
- -
name: Checkout code name: Checkout code
@@ -23,7 +27,7 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}} github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string result-encoding: string
script: | script: |
repo = await github.repos.get({ repo = await github.rest.repos.get({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
}) })
@@ -34,16 +38,24 @@ jobs:
run: | run: |
set -eu -o pipefail set -eu -o pipefail
# exclude unreleased in case re-running workflow
echo "unreleased=false" >> .github_changelog_generator
echo "max-issues=200" >> .github_changelog_generator echo "max-issues=200" >> .github_changelog_generator
# in case we've tagged subsequently ensure consistent run # cache requests to reduce load on API
NEXT_TAG_SHA1="$(git rev-list --tags --skip=0 --no-walk | grep -B 1 ${{ github.sha }} || true)" echo "cache-file=.github_changelog_generator_cache" >> .github_changelog_generator
if [[ "${NEXT_TAG_SHA1:-}" != "${{ github.sha }}" ]]
# only apply this section if triggered by a tag event
if [[ ${GITHUB_REF} == refs/tags/* ]]
then then
NEXT_TAG=$(git describe --tags --abbrev=0 ${NEXT_TAG_SHA1}) # exclude unreleased in case re-running workflow
echo "due-tag=${NEXT_TAG}" >> .github_changelog_generator echo "unreleased=false" >> .github_changelog_generator
# in case we've tagged subsequently ensure consistent run
NEXT_TAG_SHA1="$(git rev-list --tags --skip=0 --no-walk | grep -B 1 ${{ github.sha }} || true)"
if [[ "${NEXT_TAG_SHA1:-}" != "${{ github.sha }}" ]]
then
NEXT_TAG=$(git describe --tags --abbrev=0 ${NEXT_TAG_SHA1})
echo "due-tag=${NEXT_TAG}" >> .github_changelog_generator
fi
fi fi
# limit list to next tag if any # limit list to next tag if any
LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || true) LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || true)
@@ -78,6 +90,22 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
since_tag: ${{ steps.prep.outputs.previous_version }} since_tag: ${{ steps.prep.outputs.previous_version }}
output: release_notes.md output: release_notes.md
-
uses: actions/upload-artifact@v2
with:
name: release-notes
path: release_notes.md
publish-release:
name: Create Release
needs: release-notes
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
-
uses: actions/download-artifact@v2
with:
name: release-notes
- -
name: Create Release name: Create Release
id: create_release id: create_release
@@ -86,6 +114,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: ${{ github.ref }} tag_name: ${{ github.ref }}
commitish: ${{ steps.prep.outputs.release_branch }} commitish: ${{ needs.release-notes.outputs.release_branch }}
release_name: Release ${{ github.ref }} release_name: Release ${{ github.ref }}
body_path: release_notes.md body_path: release_notes.md