From 77ce29bcd1b05919853ff98e820698d8aec3e011 Mon Sep 17 00:00:00 2001 From: smarcet Date: Tue, 1 Dec 2026 17:08:23 -0300 Subject: [PATCH] chore(release): draft the release with the patch record when a vX.Y.Z tag is pushed Pushing a vX.Y.Z tag on a commit of production runs the tests and creates a draft release with generated notes and the patch record template, as openstackid does. push.yml now runs on branch pushes only and can be called by the release workflow, so a release tag runs the test suite once. --- .github/RELEASE_NOTES_TEMPLATE.md | 19 +++++++++++ .github/release.yml | 11 +++++++ .github/workflows/push.yml | 5 +++ .github/workflows/release-draft.yml | 49 +++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 .github/RELEASE_NOTES_TEMPLATE.md create mode 100644 .github/release.yml create mode 100644 .github/workflows/release-draft.yml diff --git a/.github/RELEASE_NOTES_TEMPLATE.md b/.github/RELEASE_NOTES_TEMPLATE.md new file mode 100644 index 000000000..45f9ebaf1 --- /dev/null +++ b/.github/RELEASE_NOTES_TEMPLATE.md @@ -0,0 +1,19 @@ + + +## Patch record + +- Release tag: vX.Y.Z +- Deployed to production: YYYY-MM-DD +- Components updated: list them here. A grouped Dependabot pull request shows only its group name under "Dependency updates", so copy the packages from its description. +- CVEs and advisories addressed: none diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..eb4f05bf0 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,11 @@ +# Categories for automatically generated release notes. +# Dependabot labels its pull requests "dependencies", so the components that a +# release updates are listed on their own for the patch record. +changelog: + categories: + - title: Dependency updates + labels: + - dependencies + - title: Other changes + labels: + - "*" diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c4323141e..5fd5dad07 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -2,6 +2,11 @@ name: Run Unit Tests On Push on: push: + # Branches only. A release tag runs these tests inside release-draft.yml, + # so they do not run twice for the same tag. + branches: + - "**" + workflow_call: jobs: unit-tests: diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml new file mode 100644 index 000000000..839e53e7b --- /dev/null +++ b/.github/workflows/release-draft.yml @@ -0,0 +1,49 @@ +name: Draft release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +permissions: + contents: read + +jobs: + on-production: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Tagged commit must be on production + run: | + git fetch --no-tags origin production + if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/production; then + echo "::error::tag $GITHUB_REF_NAME points to a commit that is not on production" + exit 1 + fi + + test: + needs: on-production + uses: ./.github/workflows/push.yml + secrets: inherit + + draft: + needs: test + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Create draft release + env: + GH_TOKEN: ${{ github.token }} + run: | + sed "s/vX\.Y\.Z/${GITHUB_REF_NAME}/g" .github/RELEASE_NOTES_TEMPLATE.md > "$RUNNER_TEMP/notes.md" + gh release create "$GITHUB_REF_NAME" \ + --verify-tag --draft --generate-notes \ + --notes-file "$RUNNER_TEMP/notes.md"