Skip to content

Commit 1b59955

Browse files
authored
chore: update release automation scripts 4.x (#3824)
1 parent 5244711 commit 1b59955

File tree

4 files changed

+98
-5
lines changed

4 files changed

+98
-5
lines changed

.github/scripts/highlights.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ async function pullRequestHighlights(prs) {
7070
if (!highlights.length) return '';
7171

7272
highlights.unshift('## Release Notes\n\n');
73-
return highlights.join('\n\n');
73+
74+
const highlight = highlights.join('\n\n');
75+
console.log(`Total highlight is ${highlight.length} characters long`);
76+
return highlight;
7477
}
7578

7679
console.log('List of PRs to collect highlights from:', prs);

.github/scripts/pr_list.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ const historyFilePath = path.join(__dirname, '..', '..', 'HISTORY.md');
1313
*/
1414
function parsePRList(history) {
1515
const prRegexp = /node-mongodb-native\/issues\/(?<prNum>\d+)\)/iu;
16-
return history
17-
.split('\n')
18-
.map(line => prRegexp.exec(line)?.groups?.prNum ?? '')
19-
.filter(prNum => prNum !== '');
16+
return Array.from(
17+
new Set(
18+
history
19+
.split('\n')
20+
.map(line => prRegexp.exec(line)?.groups?.prNum ?? '')
21+
.filter(prNum => prNum !== '')
22+
)
23+
);
2024
}
2125

2226
const historyContents = await fs.readFile(historyFilePath, { encoding: 'utf8' });

.github/workflows/release-4.x.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
on:
2+
push:
3+
branches: [4.x]
4+
workflow_dispatch: {}
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
id-token: write
10+
11+
name: release-4x
12+
13+
jobs:
14+
release-please:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- id: release
18+
uses: google-github-actions/release-please-action@v3
19+
with:
20+
release-type: node
21+
package-name: mongodb
22+
# Example: chore(main): release 5.7.0 [skip-ci]
23+
# ${scope} - parenthesis included, base branch name
24+
pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
25+
pull-request-header: 'Please run the release_notes action before releasing to generate release highlights'
26+
changelog-path: HISTORY.md
27+
default-branch: 4.x
28+
29+
# If release-please created a release, publish to npm
30+
- if: ${{ steps.release.outputs.release_created }}
31+
uses: actions/checkout@v3
32+
- if: ${{ steps.release.outputs.release_created }}
33+
name: actions/setup
34+
uses: ./.github/actions/setup
35+
- if: ${{ steps.release.outputs.release_created }}
36+
run: npm publish --provenance --tag=4x
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release_notes.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: release_notes
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releasePr:
7+
description: 'Enter release PR number'
8+
required: true
9+
type: number
10+
11+
jobs:
12+
release_notes:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: actions/setup
18+
uses: ./.github/actions/setup
19+
20+
# See: https://github.com/googleapis/release-please/issues/1274
21+
22+
# Get the PRs that are in this release
23+
# Outputs a list of comma seperated PR numbers, parsed from HISTORY.md
24+
- id: pr_list
25+
run: node .github/scripts/pr_list.mjs
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}
28+
29+
# From the list of PRs, gather the highlight sections of the PR body
30+
# output JSON with "highlights" key (to preserve newlines)
31+
- id: highlights
32+
run: node .github/scripts/highlights.mjs
33+
env:
34+
GITHUB_TOKEN: ${{ github.token }}
35+
PR_LIST: ${{ steps.pr_list.outputs.pr_list }}
36+
37+
# The combined output is available
38+
- id: release_notes
39+
run: node .github/scripts/release_notes.mjs
40+
env:
41+
GITHUB_TOKEN: ${{ github.token }}
42+
HIGHLIGHTS: ${{ steps.highlights.outputs.highlights }}
43+
44+
# Update the release PR body
45+
- run: gh pr edit ${{ inputs.releasePr }} --body-file ${{ steps.release_notes.outputs.release_notes_path }}
46+
shell: bash
47+
env:
48+
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy