From a4d372b61877d92949435196f2ae4251b3554885 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Mon, 3 Jul 2023 13:54:11 -0400 Subject: [PATCH 1/2] chore(NODE-5387): add release automation --- .github/actions/setup/action.yml | 15 ++ .github/pull_request_template.md | 8 + .github/scripts/highlights.mjs | 79 +++++++ .github/scripts/pr_list.mjs | 28 +++ .github/scripts/release_notes.mjs | 56 +++++ .github/scripts/util.mjs | 47 +++++ .github/workflows/lint.yml | 9 +- .github/workflows/release.yml | 37 ++++ .github/workflows/release_notes.yml | 48 +++++ package-lock.json | 311 ++++++++++++++++++++++++++++ package.json | 1 + 11 files changed, 634 insertions(+), 5 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/scripts/highlights.mjs create mode 100644 .github/scripts/pr_list.mjs create mode 100644 .github/scripts/release_notes.mjs create mode 100644 .github/scripts/util.mjs create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/release_notes.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..28e6850 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,15 @@ +name: Setup +description: 'Installs node, driver dependencies, and builds source' + +runs: + using: composite + steps: + - uses: actions/setup-node@v3 + with: + node-version: 'lts/*' + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + - run: npm install -g npm@latest + shell: bash + - run: npm clean-install + shell: bash diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 44c2639..e196cba 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -16,6 +16,14 @@ If you haven't already, it would greatly help the team review this work in a tim You can do that here: https://jira.mongodb.org/projects/NODE --> +### Release Highlight + + + +### Fill in title or leave empty for no highlight + + + ### Double check the following - [ ] Ran `npm run check:lint` script diff --git a/.github/scripts/highlights.mjs b/.github/scripts/highlights.mjs new file mode 100644 index 0000000..e6af240 --- /dev/null +++ b/.github/scripts/highlights.mjs @@ -0,0 +1,79 @@ +// @ts-check +import * as process from 'node:process'; +import { Octokit } from '@octokit/core'; +import { output } from './util.mjs'; + +const { + GITHUB_TOKEN = '', + PR_LIST = '', + owner = 'mongodb-js', + repo = 'nodejs-mongodb-legacy' +} = process.env; +if (GITHUB_TOKEN === '') throw new Error('GITHUB_TOKEN cannot be empty'); + +const octokit = new Octokit({ + auth: GITHUB_TOKEN, + log: { + debug: msg => console.error('Octokit.debug', msg), + info: msg => console.error('Octokit.info', msg), + warn: msg => console.error('Octokit.warn', msg), + error: msg => console.error('Octokit.error', msg) + } +}); + +const prs = PR_LIST.split(',').map(pr => { + const prNum = Number(pr); + if (Number.isNaN(prNum)) + throw Error(`expected PR number list: ${PR_LIST}, offending entry: ${pr}`); + return prNum; +}); + +/** @param {number} pull_number */ +async function getPullRequestContent(pull_number) { + const startIndicator = 'RELEASE_HIGHLIGHT_START -->'; + const endIndicator = '