From 449f74a4e2f8031ff24938fd3f3d02e2e07d26a4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:35:53 -0800 Subject: [PATCH] Enhance release notes automation (#3751) (#3776) * Bump versions * It now tabs every line included in the Release Notes section of the PR template (cherry picked from commit b00b22a149964730f570e294f57c7bd5f9a1b1cb) # Conflicts: # .github/workflows/config/release-notes.json # .github/workflows/release-notes.yml Co-authored-by: Jack Koenig --- .github/workflows/config/release-notes.json | 86 +++++++++++++++++++++ .github/workflows/release-notes.yml | 50 ++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 .github/workflows/config/release-notes.json create mode 100644 .github/workflows/release-notes.yml diff --git a/.github/workflows/config/release-notes.json b/.github/workflows/config/release-notes.json new file mode 100644 index 00000000000..eee182a77e7 --- /dev/null +++ b/.github/workflows/config/release-notes.json @@ -0,0 +1,86 @@ +{ + "categories": [ + { + "title": "## Features", + "labels": ["Feature"] + }, + { + "title": "## API Modification", + "labels": ["API Modification"] + }, + { + "title": "## API Deprecation", + "labels": ["Deprecation"] + }, + { + "title": "## Backend Code Generation", + "labels": ["Backend Code Generation"] + }, + { + "title": "## Performance", + "labels": ["Performance"] + }, + { + "title": "## Fixes", + "labels": ["Bugfix"] + }, + { + "title": "## Documentation", + "labels": ["Documentation"] + }, + { + "title": "## Dependency Updates", + "labels": ["Dependency Update"] + }, + { + "title": "## Build and Internal Changes", + "labels": ["Internal"] + }, + { + "title": "## Uncategorized", + "labels": [] + } + ], + "ignore_labels": [ + "No Release Notes" + ], + "sort": { + "order": "ASC", + "on_property": "mergedAt" + }, + "template": "${{CHANGELOG}}\n\n**Full Changelog:** ${{RELEASE_DIFF}}\n", + "pr_template": "- ${{TITLE}} (by @${{AUTHOR}} in ${{URL}})${{RELEASE_NOTES}}", + "empty_template": "- no changes", + "transformers": [ + { + "pattern": "", + "flags": "gus", + "target": "" + }, + { + "pattern": "\n\\s*\n", + "flags": "gu", + "target": "\n" + }, + { + "pattern": "\n", + "flags": "gu", + "target": "\n " + } + ], + "custom_placeholders": [ + { + "name": "RELEASE_NOTES", + "source": "BODY", + "transformer": { + "pattern": ".*#### Release Notes(?:[\n\\s]|(?:))*((?:\\S(?!!--)).*?)[\n\\s]*\n#.*", + "flags": "gus", + "target": "\n$1" + } + } + ], + "trim_values": false, + "max_tags_to_fetch": 200, + "max_pull_requests": 1000, + "max_back_track_time_days": 365 +} diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml new file mode 100644 index 00000000000..f3bac67dbaa --- /dev/null +++ b/.github/workflows/release-notes.yml @@ -0,0 +1,50 @@ +name: Generate Release Notes + +on: + release: + types: [created] + workflow_dispatch: + inputs: + toTag: + description: 'Tag or ref for which to generate release notes' + required: true + fromTag: + # If you leave this blank, it'll select previous SemVer version + # WARNING: Cannot use anything older than a005498 because of the git tree merge + description: 'Tag or ref from which to start generating release notes' + required: false + + +jobs: + generate_release_notes: + name: Generate Release Notes + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build Release Notes + id: release-notes + uses: mikepenz/release-changelog-builder-action@v4.1.1 + with: + configuration: .github/workflows/config/release-notes.json + failOnError: true + # Amazingly, on release where the inputs are empty, this just does the right thing + # The "toTag" is the released tag, and the "fromTag" is the previous tag according to SemVer + fromTag: ${{ github.event.inputs.fromTag }} + toTag: ${{ github.event.inputs.toTag }} + token: ${{ secrets.GITHUB_TOKEN }} + - name: Report Release Notes + # Put output through env variable to make it robust to quotes + env: + CHANGELOG: ${{steps.release-notes.outputs.changelog}} + run: echo "$CHANGELOG" >> $GITHUB_STEP_SUMMARY + - name: Upload Release Notes (on release) + if: github.event_name == 'release' + uses: softprops/action-gh-release@v0.1.15 + with: + body: ${{ steps.release-notes.outputs.changelog }} + - name: Error on uncategorized PRs + if: steps.release-notes.outputs.uncategorized_prs != 0 + run: exit 1 +