Skip to content

Commit df43731

Browse files
authored
feat: add require-pr-numbers flag for changelog generation (#181)
* feat: add require-pr-numbers flag for changelog generation Add --requirePrNumbers flag to filter out direct commits without PR numbers from changelogs. This helps maintain changelog quality for projects using strict PR-based workflows. Changes: - Add require-pr-numbers input to update-release-changelog and create-release-pr actions - Make --requirePrNumbers flag conditional based on input (defaults to false) - Add merge logic to sync changelog branch with release branch updates Requires @metamask/[email protected] with --requirePrNumbers support. * fix: address Copilot review comments - Replace eval with direct command execution for security - Add platform-specific logic to create-platform-release-pr.sh (extension uses yarn, mobile uses npx with pinned version) - Clarify documentation that require_pr_numbers is ignored for mobile - Add detailed comment explaining merge logic rationale in update-release-changelog.sh (intentionally different from create-platform-release-pr.sh) * chore: update @metamask/auto-changelog to ^5.3.0 Update to use the published version with --requirePrNumbers support. * fix: address additional Copilot review comments - Fix typo: 'heckout_or_create_branch' -> 'checkout_or_create_branch' - Improve merge conflict handling: reset to HEAD (pre-merge state) instead of release branch to preserve existing changelog content - Add clearer logging for merge conflict scenario Note: Code duplication suggestion skipped (nitpick, over-engineering) * refactor: streamline changelog generation logic - Consolidate changelog generation for both extension and mobile platforms to use yarn auto-changelog. - Remove redundant merge logic in update-release-changelog.sh to simplify the process. - Ensure consistent handling of the --requirePrNumbers flag across scripts for improved clarity and functionality. * fix: correct variable name and fix package.json formatting - Fix bug: ${new_version} -> ${VERSION} in update-release-changelog.sh - Add trailing newline to package.json for Prettier compliance * docs: remove platform-specific limitation from require_pr_numbers Standardize changelog generation for both platforms. The require-pr-numbers flag can now be used for both extension and mobile, though it's currently only enabled for extension. * refactor: always use --requirePrNumbers flag Remove conditional require-pr-numbers parameter and always apply the --requirePrNumbers flag to filter out direct commits. This simplifies the code as both extension and mobile teams have agreed to use this behavior by default.
1 parent 265e8b3 commit df43731

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

.github/scripts/create-platform-release-pr.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,13 @@ create_changelog_pr() {
347347

348348
# Generate Changelog and Test Plan
349349
echo "Generating changelog for ${platform}.."
350-
yarn auto-changelog update --rc --repo "${GITHUB_REPOSITORY_URL}" --currentVersion "${new_version}" --autoCategorize --useChangelogEntry --useShortPrLink
351-
350+
yarn auto-changelog update --rc \
351+
--repo "${GITHUB_REPOSITORY_URL}" \
352+
--currentVersion "${new_version}" \
353+
--autoCategorize \
354+
--useChangelogEntry \
355+
--useShortPrLink \
356+
--requirePrNumbers
352357

353358
# Skip commits.csv for hotfix releases (previous_version_ref is literal "null")
354359
# - When we create a new major/minor release, we fetch all commits included in the release, by fetching the diff between HEAD and previous version reference.

.github/scripts/update-release-changelog.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,15 @@ CHANGELOG_BRANCH=$(determine_changelog_branch "${VERSION}")
200200
checkout_or_create_branch "${CHANGELOG_BRANCH}" "${RELEASE_BRANCH}"
201201

202202
echo "Generating changelog for ${PLATFORM} ${VERSION}.."
203-
if [[ "${PLATFORM}" == "extension" ]]; then
204-
yarn auto-changelog update --rc --repo "${GITHUB_REPOSITORY_URL}" --currentVersion "${VERSION}" --autoCategorize --useChangelogEntry --useShortPrLink
205-
else
206-
npx @metamask/[email protected] update --rc --repo "${GITHUB_REPOSITORY_URL}" --currentVersion "${VERSION}" --autoCategorize
207-
fi
203+
204+
yarn auto-changelog update --rc \
205+
--repo "${GITHUB_REPOSITORY_URL}" \
206+
--currentVersion "${VERSION}" \
207+
--autoCategorize \
208+
--useChangelogEntry \
209+
--useShortPrLink \
210+
--requirePrNumbers
208211

209212
# commits.csv generation removed (no longer required)
210213

211214
commit_and_push_changelog "${VERSION}" "${PREVIOUS_VERSION_REF}" "${CHANGELOG_BRANCH}" "${RELEASE_BRANCH}"
212-

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"update-release-sheet": "node .github/scripts/update-release-sheet.mjs"
2727
},
2828
"dependencies": {
29-
"@metamask/auto-changelog": "^5.2.0",
29+
"@metamask/auto-changelog": "^5.3.0",
3030
"@metamask/utils": "^7.1.0",
3131
"@octokit/graphql": "^7.0.1",
3232
"@octokit/request": "^8.1.1",

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,9 @@ __metadata:
941941
languageName: node
942942
linkType: hard
943943

944-
"@metamask/auto-changelog@npm:^5.2.0":
945-
version: 5.2.0
946-
resolution: "@metamask/auto-changelog@npm:5.2.0"
944+
"@metamask/auto-changelog@npm:^5.3.0":
945+
version: 5.3.0
946+
resolution: "@metamask/auto-changelog@npm:5.3.0"
947947
dependencies:
948948
"@octokit/rest": "npm:^20.0.0"
949949
diff: "npm:^5.0.0"
@@ -954,7 +954,7 @@ __metadata:
954954
prettier: ">=3.0.0"
955955
bin:
956956
auto-changelog: dist/cli.mjs
957-
checksum: 10/86ca4f56a0c86a1fabbe4b7b66a28bda39e59c51c996aadedeb5f341b3e93acfd7ca5dafebbd82852070f12324bbd83fc7cb979cb9f8b9ca8f5dded53f1fa5af
957+
checksum: 10/5381c2b1efbade000bafbbee7b1becbee1787b9f24849352d16ddd3b14f511f865b3478250301f3d22f98fe0208690f62f166a476e64d38ed58361d816a673b6
958958
languageName: node
959959
linkType: hard
960960

@@ -1014,7 +1014,7 @@ __metadata:
10141014
dependencies:
10151015
"@lavamoat/allow-scripts": "npm:^2.3.1"
10161016
"@lavamoat/preinstall-always-fail": "npm:^1.0.0"
1017-
"@metamask/auto-changelog": "npm:^5.2.0"
1017+
"@metamask/auto-changelog": "npm:^5.3.0"
10181018
"@metamask/eslint-config": "npm:^12.0.0"
10191019
"@metamask/eslint-config-jest": "npm:^12.0.0"
10201020
"@metamask/eslint-config-nodejs": "npm:^12.0.0"

0 commit comments

Comments
 (0)