From 44373ae11f11c7818fc5043427a227411d333b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 26 May 2025 13:56:32 +0200 Subject: [PATCH 1/3] chore(ci): support separate release notes per module --- .github/release-drafter-template.yml | 83 +++++++++++++++++++++++++++ .github/release-drafter.yml | 50 ---------------- .github/workflows/release-drafter.yml | 65 ++++++++++++++++++++- 3 files changed, 146 insertions(+), 52 deletions(-) create mode 100644 .github/release-drafter-template.yml delete mode 100644 .github/release-drafter.yml diff --git a/.github/release-drafter-template.yml b/.github/release-drafter-template.yml new file mode 100644 index 0000000000..51ef58fa0b --- /dev/null +++ b/.github/release-drafter-template.yml @@ -0,0 +1,83 @@ +# For core module (empty folder), we want: +# - tag: v1.0.0 +# - name: v1.0.0 +# For other modules (modulegen, modules/mssql), we want: +# - tag: modulegen/v1.0.0 or modules/mssql/v1.0.0 +# - name: modulegen - v1.0.0 or modules/mssql - v1.0.0 +name-template: '{{FOLDER}}{{FOLDER_SEP}}v$RESOLVED_VERSION' +tag-template: '{{FOLDER}}{{FOLDER_SLASH}}v$RESOLVED_VERSION' +tag-prefix: '{{FOLDER}}{{FOLDER_SLASH}}v' +include-paths: + - {{FOLDER}} +categories: + - title: โš ๏ธ Breaking Changes + labels: + - 'breaking change' + - title: ๐Ÿ”’ Security + labels: + - 'security' + - title: ๐Ÿš€ Features + labels: + - 'enhancement' + - 'feature' + - title: ๐Ÿ› Bug Fixes + labels: + - 'bug' + - title: ๐Ÿ“– Documentation + labels: + - 'documentation' + - title: ๐Ÿงน Housekeeping + labels: + - 'chore' + - 'test flakiness' + - title: ๐Ÿ“ฆ Dependency updates + label: 'dependencies' +change-template: '- $TITLE (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +exclude-contributors: + - dependabot + - dependabot[bot] +version-resolver: + major: + labels: + - 'breaking change' + minor: + labels: + - 'feature' + - 'security' + patch: + labels: + - 'bug' + - 'chore' + - 'documentation' + - 'dependencies' + default: patch +template: | + # What's Changed + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...{{FOLDER}}/v$RESOLVED_VERSION + + Thank you $CONTRIBUTORS for making this update possible. +autolabeler: + - label: 'breaking change' + title: + - '/^[a-z]+(\(.+\))?!\:/' + - label: 'security' + title: + - '/^security(\(.+\))?!?\:/' + - label: 'feature' + title: + - '/^feat(\(.+\))?!?\:/' + - label: 'bug' + title: + - '/^(fix)(\(.+\))?!?\:/' + - label: 'documentation' + title: + - '/^docs(\(.+\))?!?\:/' + - label: 'chore' + title: + - '/^chore(\(.+\))?!?\:/' + - label: 'dependencies' + title: + - '/^deps(\(.+\))?!?\:/' diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 2e5efff2b1..0000000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,50 +0,0 @@ -name-template: v$NEXT_PATCH_VERSION -tag-template: v$NEXT_PATCH_VERSION -template: | - # What's Changed - $CHANGES -categories: - - title: โš ๏ธ Breaking Changes - labels: - - 'breaking change' - - title: ๐Ÿ”’ Security - labels: - - 'security' - - title: ๐Ÿš€ Features - labels: - - 'enhancement' - - 'feature' - - title: ๐Ÿ› Bug Fixes - labels: - - 'bug' - - title: ๐Ÿ“– Documentation - labels: - - 'documentation' - - title: ๐Ÿงน Housekeeping - labels: - - 'chore' - - 'test flakiness' - - title: ๐Ÿ“ฆ Dependency updates - label: 'dependencies' -autolabeler: - - label: 'breaking change' - title: - - '/^[a-z]+(\(.+\))?!\:/' - - label: 'security' - title: - - '/^security(\(.+\))?!?\:/' - - label: 'feature' - title: - - '/^feat(\(.+\))?!?\:/' - - label: 'bug' - title: - - '/^(fix)(\(.+\))?!?\:/' - - label: 'documentation' - title: - - '/^docs(\(.+\))?!?\:/' - - label: 'chore' - title: - - '/^chore(\(.+\))?!?\:/' - - label: 'dependencies' - title: - - '/^deps(\(.+\))?!?\:/' diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 7f64281774..e7b72f9fab 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -14,14 +14,75 @@ permissions: contents: read jobs: + detect-modules: + runs-on: ubuntu-latest + outputs: + modules: ${{ steps.set-modified-modules.outputs.modules }} + modules_count: ${{ steps.set-modified-modules-count.outputs.modules_count }} + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - id: changed-files + name: Get changed files + uses: tj-actions/changed-files@823fcebdb31bb35fdf2229d9f769b400309430d0 # v46.0.3 + + - id: set-modified-modules + name: Set all modified modules + env: + ALL_CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}" + run: echo "modules=$(./scripts/changed-modules.sh)" >> $GITHUB_OUTPUT + + - id: set-modified-modules-count + name: Set all modified modules count + run: echo "modules_count=$(echo ${{ toJSON(steps.set-modified-modules.outputs.modules) }} | jq '. | length')" >> $GITHUB_OUTPUT + + - name: Print out the modules to be used + run: | + echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build" + echo "${{ steps.set-modified-modules.outputs.modules }}" + update_release_draft: + needs: detect-modules + if: ${{ needs.detect-modules.outputs.modules_count > 0 }} permissions: contents: write # for release-drafter/release-drafter to create a github release pull-requests: write # for release-drafter/release-drafter to add label to PR runs-on: ubuntu-latest + strategy: + matrix: + module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} steps: - - uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0 + - name: Check out code into the Go module directory + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: - disable-autolabeler: false + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + + - name: Generate dynamic config from template + id: generate-config + run: | + folder="${{ matrix.module }}" + if [ -z "$folder" ]; then + # Core module + folder_sep="" + folder_slash="" + else + # Any other module + folder_sep=" - " + folder_slash="/" + fi + sed -e "s|{{FOLDER}}|$folder|g" \ + -e "s|{{FOLDER_SEP}}|$folder_sep|g" \ + -e "s|{{FOLDER_SLASH}}|$folder_slash|g" \ + .github/release-drafter-template.yml > .github/release-drafter-$folder.yml + echo "config<> $GITHUB_OUTPUT + cat .github/release-drafter-$folder.yml >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Use dynamic release-drafter configuration env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ReneWerner87/release-drafter@6dec4ceb1fb86b6514f11a2e7a39e1dedce709d0 + with: + config: ${{ steps.generate-config.outputs.config }} From 3e923ab32cc52d9da8e27f3af5a02a330d4e5f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 26 May 2025 14:01:43 +0200 Subject: [PATCH 2/3] fix: sanitise names --- .github/workflows/release-drafter.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e7b72f9fab..5b4feb82f9 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -67,17 +67,20 @@ jobs: # Core module folder_sep="" folder_slash="" + folder_filename="core" else # Any other module folder_sep=" - " folder_slash="/" + # Sanitize folder name for filename by replacing / with - + folder_filename=$(echo "$folder" | tr '/' '-') fi sed -e "s|{{FOLDER}}|$folder|g" \ -e "s|{{FOLDER_SEP}}|$folder_sep|g" \ -e "s|{{FOLDER_SLASH}}|$folder_slash|g" \ - .github/release-drafter-template.yml > .github/release-drafter-$folder.yml + .github/release-drafter-template.yml > .github/release-drafter-$folder_filename.yml echo "config<> $GITHUB_OUTPUT - cat .github/release-drafter-$folder.yml >> $GITHUB_OUTPUT + cat .github/release-drafter-$folder_filename.yml >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - name: Use dynamic release-drafter configuration From 9cbfd7b2553cebd012ea4bd2f874b5cc768048c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 26 May 2025 14:04:31 +0200 Subject: [PATCH 3/3] fix: add folder path for the core --- .github/release-drafter-template.yml | 2 +- .github/workflows/release-drafter.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/release-drafter-template.yml b/.github/release-drafter-template.yml index 51ef58fa0b..7fc0b3c47b 100644 --- a/.github/release-drafter-template.yml +++ b/.github/release-drafter-template.yml @@ -8,7 +8,7 @@ name-template: '{{FOLDER}}{{FOLDER_SEP}}v$RESOLVED_VERSION' tag-template: '{{FOLDER}}{{FOLDER_SLASH}}v$RESOLVED_VERSION' tag-prefix: '{{FOLDER}}{{FOLDER_SLASH}}v' include-paths: - - {{FOLDER}} + - {{FOLDER_PATH}} categories: - title: โš ๏ธ Breaking Changes labels: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 5b4feb82f9..3f117223ba 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -68,15 +68,18 @@ jobs: folder_sep="" folder_slash="" folder_filename="core" + folder_path="." else # Any other module folder_sep=" - " folder_slash="/" # Sanitize folder name for filename by replacing / with - folder_filename=$(echo "$folder" | tr '/' '-') + folder_path="$folder" fi sed -e "s|{{FOLDER}}|$folder|g" \ -e "s|{{FOLDER_SEP}}|$folder_sep|g" \ + -e "s|{{FOLDER_PATH}}|$folder_path|g" \ -e "s|{{FOLDER_SLASH}}|$folder_slash|g" \ .github/release-drafter-template.yml > .github/release-drafter-$folder_filename.yml echo "config<> $GITHUB_OUTPUT