From c8fdce3d67316da4d7143b8b1fa0e0a9f556da51 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Wed, 5 Jul 2023 11:46:37 -0700 Subject: [PATCH 1/3] Add release note automation --- .github/workflows/config/release-notes.json | 56 +++++++++++++++++++++ .github/workflows/release-notes.yml | 46 +++++++++++++++++ .github/workflows/require-label.yml | 24 +++++++++ 3 files changed, 126 insertions(+) create mode 100644 .github/workflows/config/release-notes.json create mode 100644 .github/workflows/release-notes.yml create mode 100644 .github/workflows/require-label.yml diff --git a/.github/workflows/config/release-notes.json b/.github/workflows/config/release-notes.json new file mode 100644 index 00000000..d6098d7b --- /dev/null +++ b/.github/workflows/config/release-notes.json @@ -0,0 +1,56 @@ +{ + "categories": [ + { + "title": "## Added", + "labels": ["changelog:added"] + }, + { + "title": "## Changed", + "labels": ["changelog:changed"] + }, + { + "title": "## Fixed", + "labels": ["changelog:fixed"] + }, + { + "title": "## Removed", + "labels": ["changelog:removed"] + }, + { + "title": "## Uncategorized", + "labels": [] + } + ], + "ignore_labels": [ + "changelog:omit" + ], + "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": "" + } + ], + "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": 500, + "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 00000000..c480ecb7 --- /dev/null +++ b/.github/workflows/release-notes.yml @@ -0,0 +1,46 @@ +# adapted from https://github.com/chipsalliance/chisel/blob/main/.github/workflows/release-notes.yml + +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-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build Release Notes + id: release-notes + uses: mikepenz/release-changelog-builder-action@v3.7.0 + 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 + run: echo '${{steps.release-notes.outputs.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 diff --git a/.github/workflows/require-label.yml b/.github/workflows/require-label.yml new file mode 100644 index 00000000..0088f6bd --- /dev/null +++ b/.github/workflows/require-label.yml @@ -0,0 +1,24 @@ +# adapted from https://github.com/chipsalliance/chisel/blob/main/.github/workflows/require-label.yml + +name: Require Release Notes Label + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + - reopened + - labeled + - unlabeled + +jobs: + check_labels: + name: Check Labels + runs-on: ubuntu-latest + steps: + - uses: docker://agilepathway/pull-request-label-checker:v1.4.25 + with: + one_of: changelog:added,changelog:changed,changelog:fixed,changelog:omit,changelog:removed + repo_token: ${{ secrets.GITHUB_TOKEN }} From 33f2bd866d55d3eb0014a6026f2cdf5cbf1c6172 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Wed, 5 Jul 2023 11:49:31 -0700 Subject: [PATCH 2/3] Update release workflow --- .github/workflows/release-notes.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml index c480ecb7..ce047d5f 100644 --- a/.github/workflows/release-notes.yml +++ b/.github/workflows/release-notes.yml @@ -16,10 +16,12 @@ on: description: 'Tag or ref from which to start generating release notes' required: false + jobs: generate_release_notes: name: Generate Release Notes runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v3 @@ -35,7 +37,10 @@ jobs: toTag: ${{ github.event.inputs.toTag }} token: ${{ secrets.GITHUB_TOKEN }} - name: Report Release Notes - run: echo '${{steps.release-notes.outputs.changelog}}' >> $GITHUB_STEP_SUMMARY + # 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 From 2ba7de177629b4b98d74534a2d126c76da378e8b Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Wed, 5 Jul 2023 11:51:22 -0700 Subject: [PATCH 3/3] Remove the old mergify label checking --- .mergify.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index 5025ab18..0615acdc 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -22,21 +22,3 @@ pull_request_rules: actions: label: add: [Backport] - - - name: check PR has changelog label - conditions: - - base=main - actions: - post_check: - success_conditions: - - "label~=^changelog:" - title: | - {% if check_succeed %} - Labeled for changelog - {% else %} - Needs label for changelog - {% endif %} - summary: | - {% if not check_succeed %} - Your pull request must have a changelog label (e.g. `changelog: ...`). - {% endif %}