Skip to content

Commit

Permalink
chore: update release automation scripts 5.x (#3823)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Aug 17, 2023
1 parent c0d3927 commit e1af343
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/highlights.mjs
Expand Up @@ -70,7 +70,10 @@ async function pullRequestHighlights(prs) {
if (!highlights.length) return '';

highlights.unshift('## Release Notes\n\n');
return highlights.join('\n\n');

const highlight = highlights.join('\n\n');
console.log(`Total highlight is ${highlight.length} characters long`);
return highlight;
}

console.log('List of PRs to collect highlights from:', prs);
Expand Down
12 changes: 8 additions & 4 deletions .github/scripts/pr_list.mjs
Expand Up @@ -13,10 +13,14 @@ const historyFilePath = path.join(__dirname, '..', '..', 'HISTORY.md');
*/
function parsePRList(history) {
const prRegexp = /node-mongodb-native\/issues\/(?<prNum>\d+)\)/iu;
return history
.split('\n')
.map(line => prRegexp.exec(line)?.groups?.prNum ?? '')
.filter(prNum => prNum !== '');
return Array.from(
new Set(
history
.split('\n')
.map(line => prRegexp.exec(line)?.groups?.prNum ?? '')
.filter(prNum => prNum !== '')
)
);
}

const historyContents = await fs.readFile(historyFilePath, { encoding: 'utf8' });
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-4.x.yml
Expand Up @@ -6,6 +6,7 @@ on:
permissions:
contents: write
pull-requests: write
id-token: write

name: release-4x

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/release-5.x.yml
@@ -0,0 +1,38 @@
on:
push:
branches: [5.x]
workflow_dispatch: {}

permissions:
contents: write
pull-requests: write
id-token: write

name: release-5x

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- id: release
uses: google-github-actions/release-please-action@v3
with:
release-type: node
package-name: mongodb
# Example: chore(main): release 5.7.0 [skip-ci]
# ${scope} - parenthesis included, base branch name
pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
pull-request-header: 'Please run the release_notes action before releasing to generate release highlights'
changelog-path: HISTORY.md
default-branch: 5.x

# If release-please created a release, publish to npm
- if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v3
- if: ${{ steps.release.outputs.release_created }}
name: actions/setup
uses: ./.github/actions/setup
- if: ${{ steps.release.outputs.release_created }}
run: npm publish --provenance --tag=5x
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 3 additions & 2 deletions .github/workflows/release-alpha.yml
Expand Up @@ -8,13 +8,14 @@ on:
required: true
type: string

permissions:
id-token: write

name: release-alpha

jobs:
release-alpha:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- shell: bash
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-nightly.yml
Expand Up @@ -11,13 +11,14 @@ on:
# As long as the commit hash has changed on main a release will be published
workflow_dispatch: {}

permissions:
id-token: write

name: release-nightly

jobs:
release-nightly:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: actions/setup
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Expand Up @@ -6,6 +6,7 @@ on:
permissions:
contents: write
pull-requests: write
id-token: write

name: release

Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -62,7 +62,7 @@
"@microsoft/api-extractor": "^7.35.1",
"@microsoft/tsdoc-config": "^0.16.2",
"@mongodb-js/zstd": "^1.1.0",
"@octokit/core": "^4.2.1",
"@octokit/core": "^4.2.4",
"@types/chai": "^4.3.5",
"@types/chai-subset": "^1.3.3",
"@types/express": "^4.17.17",
Expand Down

0 comments on commit e1af343

Please sign in to comment.