Skip to content

Commit 8bebfde

Browse files
authored
ci: preview release notes on bump dry run (3.x) (#18981)
Ports [#18796](#18796) from main to 3.x. A `release-bump` dry run now shows the release notes that the real release will get. It also removes the local `pnpm release` fallback. ```diff .github/workflows/ └── publish-release.yml # drops the [skip ci] check tools/releaser/src/ ├── release-bump.ts # dry run previews notes ├── release-ci.ts # uses listReleaseTags -├── release.ts # local release fallback ├── lib/ +│ ├── listReleaseTags.ts # lists v3.* tags +│ ├── writeStepSummary.ts # appends to the job summary -│ └── publishLocalRelease.ts └── utils/ └── generateReleaseNotes.ts # optional releaseTag ``` v3.92.0 was the first 3.x release from CI. Its dry run showed only the git commands. The notes first appeared in the draft GitHub release, after the npm publish. ## Changes - **Release notes preview on dry run** - A dry run finds the changelog base tag. It generates notes for `base..HEAD`, labeled with the next version. - The notes go to the log and to `$GITHUB_STEP_SUMMARY` (the Markdown job summary on the run page). - A missing base tag fails the dry run. A real run skips the preview. - **Release notes generation** - `generateReleaseNotes` takes an optional `releaseTag`. It sets the version in the heading, compare link, and release URL. - The `chore(release): vX` commit filter applies to every range. Before, it applied to tag ranges only. - **Shared tag listing** - `release-bump` and `release-ci` list `v3.*` tags through one `listReleaseTags` helper. - **Local release path** - Deletes `release.ts`, `publishLocalRelease`, both `release` scripts, and the `prompts` dependencies. - Drops the `[skip ci]` check from `publish-release`. The check only stopped a second publish after a local release. ## Design Decisions - **Preview only from #18796.** That PR also brought the 3.x hardening fixes to main: publish order, push rebase retry, and registry retries. 3.x already has them from [#18717](#18717). - **Local fallback removed.** The `Release tags` ruleset lets only the release bot create `v3.*` tags. A local `pnpm release` cannot push its tag. Its printed resume steps also tell the maintainer to push one. - **Same notes as CI.** The preview uses the same base-tag lookup and notes function as `release-ci`. Only the heading date and commits merged after the dry run can differ. ## Overall Flow ```diff release-bump --dry-run compute next version check next version is not on npm + find base tag (newest published v3 tag below the next version) + generate notes for base..HEAD, labeled with the next version + write notes to the log and the job summary log git commands, push nothing ``` ## References / Links - [Adding a job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary): how `$GITHUB_STEP_SUMMARY` renders Markdown on the run page. 🤖 Written with AI
1 parent ea3778b commit 8bebfde

14 files changed

Lines changed: 189 additions & 636 deletions

‎.github/workflows/publish-release.yml‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ concurrency:
1818
jobs:
1919
publish:
2020
name: publish-release-${{ github.ref_name }}
21-
# A local `pnpm release` commits with [skip ci] and publishes itself, so its tag push
22-
# must not start a second publish. The CI bump commit never carries [skip ci].
23-
if: >-
24-
github.repository == 'payloadcms/payload' &&
25-
!contains(github.event.head_commit.message, '[skip ci]')
21+
if: github.repository == 'payloadcms/payload'
2622
runs-on: ubuntu-26.04
2723
environment: release
2824
permissions:

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"prepare-run-test-against-prod:ci": "rm -rf test/packed && rm -rf test/node_modules && rm -rf app && rm -f test/pnpm-lock.yaml && pnpm run script:pack --all --no-build --dest test/packed && pnpm runts test/setupProd.ts && cd test && pnpm i && cd ..",
9797
"publish-prerelease": "pnpm --filter releaser publish-prerelease",
9898
"reinstall": "pnpm clean:all && pnpm install",
99-
"release": "pnpm --filter releaser release",
10099
"release-bump": "pnpm --filter releaser release-bump",
101100
"release-ci": "pnpm --filter releaser release-ci",
102101
"release-sbom": "pnpm --filter releaser release-sbom",

‎pnpm-lock.yaml‎

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tools/releaser/package.json‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"lint:fix": "eslint . --fix",
3131
"list-published": "tsx src/list-published.ts",
3232
"publish-prerelease": "tsx src/publish-prerelease.ts",
33-
"release": "tsx src/release.ts",
3433
"release-bump": "tsx src/release-bump.ts",
3534
"release-ci": "tsx src/release-ci.ts",
3635
"release-sbom": "tsx src/release-sbom.ts",
@@ -44,13 +43,11 @@
4443
"execa": "5.1.1",
4544
"minimist": "1.2.8",
4645
"p-limit": "^5.0.0",
47-
"prompts": "2.4.2",
4846
"semver": "^7.5.4",
4947
"tsx": "^4.19.2"
5048
},
5149
"devDependencies": {
5250
"@types/minimist": "1.2.5",
53-
"@types/prompts": "^2.4.5",
5451
"@types/semver": "^7.5.3"
5552
}
5653
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { execFileSync } from 'child_process'
2+
3+
import { pinnedMajorTagGlob } from './pinnedMajor.js'
4+
5+
/** Lists local git tags on the pinned major, e.g. `v3.*`. */
6+
export const listReleaseTags = (): string[] =>
7+
execFileSync('git', ['tag', '--list', pinnedMajorTagGlob], { encoding: 'utf8' })
8+
.split('\n')
9+
.map((line) => line.trim())
10+
.filter(Boolean)

‎tools/releaser/src/lib/publishLocalRelease.spec.ts‎

Lines changed: 0 additions & 111 deletions
This file was deleted.

‎tools/releaser/src/lib/publishLocalRelease.ts‎

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from 'fs'
2+
import os from 'os'
3+
import path from 'path'
4+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
5+
6+
import { writeStepSummary } from './writeStepSummary.js'
7+
8+
describe('writeStepSummary', () => {
9+
let tempDir: string
10+
11+
beforeEach(() => {
12+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'summary-'))
13+
})
14+
15+
afterEach(() => {
16+
fs.rmSync(tempDir, { force: true, recursive: true })
17+
})
18+
19+
it('should append markdown to the summary file', () => {
20+
const summaryPath = path.join(tempDir, 'summary.md')
21+
22+
writeStepSummary({ markdown: '# a', summaryPath })
23+
writeStepSummary({ markdown: '# b', summaryPath })
24+
25+
expect(fs.readFileSync(summaryPath, 'utf8')).toBe('# a\n# b\n')
26+
})
27+
28+
it('should do nothing when summaryPath is undefined', () => {
29+
expect(() => writeStepSummary({ markdown: '# a', summaryPath: undefined })).not.toThrow()
30+
})
31+
})

‎tools/releaser/src/release-bump.spec.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { runReleaseBump } from './release-bump.js'
44

55
const baseDeps = () => ({
66
env: { GITHUB_TOKEN: 'token' } as NodeJS.ProcessEnv,
7+
findChangelogBaseTag: vi.fn(async (): Promise<string | undefined> => 'v3.90.2'),
8+
generateReleaseNotes: vi.fn(async () => ({ releaseNotes: '## notes' })),
79
getCommitBump: vi.fn(async (): Promise<null | string> => 'patch'),
810
isPublished: vi.fn(async () => false),
911
log: vi.fn(),
@@ -13,6 +15,7 @@ const baseDeps = () => ({
1315
bumpVersion: vi.fn(async () => '3.90.3'),
1416
version: vi.fn(async () => '3.90.2'),
1517
},
18+
writeSummary: vi.fn(),
1619
})
1720

1821
const makeDeps = (
@@ -107,4 +110,41 @@ describe('runReleaseBump', () => {
107110
const logs = deps.log.mock.calls.map((call) => call[0] as string)
108111
expect(logs.some((line) => line.includes('git push --atomic'))).toBe(true)
109112
})
113+
114+
it('should preview release notes for the bumped version in dry-run', async () => {
115+
const deps = makeDeps()
116+
117+
await runReleaseBump({ bump: 'auto', deps, dryRun: true })
118+
119+
expect(deps.findChangelogBaseTag).toHaveBeenCalledWith({ version: '3.90.3' })
120+
expect(deps.generateReleaseNotes).toHaveBeenCalledWith({
121+
fromVersion: 'v3.90.2',
122+
releaseTag: 'v3.90.3',
123+
toVersion: 'HEAD',
124+
})
125+
126+
const logs = deps.log.mock.calls.map((call) => call[0] as string)
127+
expect(logs.some((line) => line.includes('## notes'))).toBe(true)
128+
expect(deps.writeSummary).toHaveBeenCalledWith('## notes')
129+
})
130+
131+
it('should fail the dry run when no changelog base tag exists', async () => {
132+
const deps = makeDeps({ findChangelogBaseTag: vi.fn(async () => undefined) })
133+
134+
await expect(runReleaseBump({ bump: 'auto', deps, dryRun: true })).rejects.toThrow(
135+
/changelog base tag/,
136+
)
137+
138+
expect(deps.run).not.toHaveBeenCalled()
139+
})
140+
141+
it('should not generate notes on a real run', async () => {
142+
const deps = makeDeps()
143+
144+
await runReleaseBump({ bump: 'auto', deps, dryRun: false })
145+
146+
expect(deps.findChangelogBaseTag).not.toHaveBeenCalled()
147+
expect(deps.generateReleaseNotes).not.toHaveBeenCalled()
148+
expect(deps.writeSummary).not.toHaveBeenCalled()
149+
})
110150
})

0 commit comments

Comments
 (0)