From e1af3437c309c145e2af6ebceb005771b10e736a Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 17 Aug 2023 17:41:02 -0400 Subject: [PATCH] chore: update release automation scripts 5.x (#3823) --- .github/scripts/highlights.mjs | 5 +++- .github/scripts/pr_list.mjs | 12 ++++++--- .github/workflows/release-4.x.yml | 1 + .github/workflows/release-5.x.yml | 38 +++++++++++++++++++++++++++ .github/workflows/release-alpha.yml | 5 ++-- .github/workflows/release-nightly.yml | 5 ++-- .github/workflows/release.yml | 1 + package-lock.json | 8 +++--- package.json | 2 +- 9 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/release-5.x.yml diff --git a/.github/scripts/highlights.mjs b/.github/scripts/highlights.mjs index 49cea1bff1..6df213dced 100644 --- a/.github/scripts/highlights.mjs +++ b/.github/scripts/highlights.mjs @@ -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); diff --git a/.github/scripts/pr_list.mjs b/.github/scripts/pr_list.mjs index 68639e2dea..6b31cd25c1 100644 --- a/.github/scripts/pr_list.mjs +++ b/.github/scripts/pr_list.mjs @@ -13,10 +13,14 @@ const historyFilePath = path.join(__dirname, '..', '..', 'HISTORY.md'); */ function parsePRList(history) { const prRegexp = /node-mongodb-native\/issues\/(?\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' }); diff --git a/.github/workflows/release-4.x.yml b/.github/workflows/release-4.x.yml index 46e948683c..dcda4e2d82 100644 --- a/.github/workflows/release-4.x.yml +++ b/.github/workflows/release-4.x.yml @@ -6,6 +6,7 @@ on: permissions: contents: write pull-requests: write + id-token: write name: release-4x diff --git a/.github/workflows/release-5.x.yml b/.github/workflows/release-5.x.yml new file mode 100644 index 0000000000..f909eefc7d --- /dev/null +++ b/.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 }} diff --git a/.github/workflows/release-alpha.yml b/.github/workflows/release-alpha.yml index 73abc2a957..937ba537f2 100644 --- a/.github/workflows/release-alpha.yml +++ b/.github/workflows/release-alpha.yml @@ -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: | diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index 4409562cc5..0be13e3c12 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2200b5b4ce..7cc1ca92af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,7 @@ on: permissions: contents: write pull-requests: write + id-token: write name: release diff --git a/package-lock.json b/package-lock.json index 535efa5517..ca410c2505 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,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", @@ -2406,9 +2406,9 @@ } }, "node_modules/@octokit/core": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-4.2.1.tgz", - "integrity": "sha512-tEDxFx8E38zF3gT7sSMDrT1tGumDgsw5yPG6BBh/X+5ClIQfMH/Yqocxz1PnHx6CHyF6pxmovUTOfZAUvQ0Lvw==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-4.2.4.tgz", + "integrity": "sha512-rYKilwgzQ7/imScn3M9/pFfUf4I1AZEH3KhyJmtPdE2zfaXAn2mFfUy4FbKewzc2We5y/LlKLj36fWJLKC2SIQ==", "dev": true, "dependencies": { "@octokit/auth-token": "^3.0.0", diff --git a/package.json b/package.json index a33e2faf91..6d1c2a3de2 100644 --- a/package.json +++ b/package.json @@ -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",