From de3b252845c18ad9155a60d1ecc1977e90484a3b Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 1 Feb 2023 10:53:29 +0000 Subject: [PATCH] build: Add `yarn changelog` command --- docs/publishing-a-release.md | 3 +-- package.json | 1 + scripts/get-commit-list.ts | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 scripts/get-commit-list.ts diff --git a/docs/publishing-a-release.md b/docs/publishing-a-release.md index 1b83a9a7e7c5..642fd2e51899 100644 --- a/docs/publishing-a-release.md +++ b/docs/publishing-a-release.md @@ -17,10 +17,9 @@ _These steps are only relevant to Sentry employees when preparing and publishing ## Updating the Changelog 1. Create a new branch. -2. Run `git log --format="- %s"` and copy everything since the last release. +2. Run `yarn changelog` and copy everything 3. Create a new section in the changelog, deciding based on the changes whether it should be a minor bump or a patch release. 4. Paste in the logs you copied earlier. 5. Delete any which aren't user-facing changes. -6. Alphabetize the rest. 7. If any of the PRs are from external contributors, include underneath the commits `Work in this release contributed by . Thank you for your contributions!`. If there's only one external PR, don't forget to remove the final `s`. If there are three or more, use an Oxford comma. (It's in the Sentry styleguide!) 8. Commit, push, and open a PR with the title `meta: Update changelog for ` against `develop` branch. diff --git a/package.json b/package.json index 4c5b61e8ed7b..c63448d7a220 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "clean:all": "run-p clean:build clean:caches clean:deps", "codecov": "codecov", "fix": "lerna run fix", + "changelog": "ts-node ./scripts/get-commit-list.ts", "link:yarn": "lerna exec yarn link", "lint": "lerna run lint", "lint:eslint": "lerna run lint:eslint", diff --git a/scripts/get-commit-list.ts b/scripts/get-commit-list.ts new file mode 100644 index 000000000000..e64645692ed4 --- /dev/null +++ b/scripts/get-commit-list.ts @@ -0,0 +1,23 @@ +import { execSync } from 'child_process'; + +function run(): void { + const commits = execSync('git log --format="- %s"').toString().split('\n'); + + const lastReleasePos = commits.findIndex(commit => commit.includes("Merge branch 'release")); + + const newCommits = commits.splice(0, lastReleasePos).filter(commit => { + // Filter out master/develop merges + if (/Merge pull request #(\d+) from getsentry\/(master|develop)/.test(commit)) { + return false; + } + + return true; + }); + + newCommits.sort((a, b) => a.localeCompare(b)); + + // eslint-disable-next-line no-console + console.log(newCommits.join('\n')); +} + +run();