Skip to content

Commit 35ec16f

Browse files
authored
chore: backport release scripting to 5.x branch (#624)
1 parent 63fb316 commit 35ec16f

File tree

5 files changed

+85
-5
lines changed

5 files changed

+85
-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 = /js-bson\/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-5.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: [5.x]
4+
workflow_dispatch: {}
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
id-token: write
10+
11+
name: release-5x
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: bson
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: 5.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=5x
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
on:
2+
# Allows us to manually trigger an alpha
3+
# workflow_dispatch can be given an alternative 'ref' to release from a feature branch
4+
workflow_dispatch:
5+
inputs:
6+
alphaVersion:
7+
description: 'Enter alpha version'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
id-token: write
13+
14+
name: release-alpha
15+
16+
jobs:
17+
release-alpha:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- shell: bash
21+
run: |
22+
ALPHA_SEMVER_REGEXP="-alpha(\.([0-9]|[1-9][0-9]+))?$"
23+
24+
if ! [[ "${{ inputs.alphaVersion }}" =~ $ALPHA_SEMVER_REGEXP ]]; then
25+
echo "Invalid alphaVersion string"
26+
exit 1
27+
fi
28+
- uses: actions/checkout@v3
29+
- name: actions/setup
30+
uses: ./.github/actions/setup
31+
- run: npm version "${{ inputs.alphaVersion }}" --git-tag-version=false
32+
- run: npm publish --provenance --tag=alpha
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
permissions:
77
contents: write
88
pull-requests: write
9+
id-token: write
910

1011
name: release
1112

0 commit comments

Comments
 (0)