Skip to content

Commit 9ded2fc

Browse files
chore(NODE-6822): add release tooling to v6.6.x branch (#775)
Co-authored-by: Warren James <[email protected]>
1 parent eeab1e8 commit 9ded2fc

File tree

7 files changed

+209
-21
lines changed

7 files changed

+209
-21
lines changed

.github/scripts/highlights.mjs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
// @ts-check
22
import * as process from 'node:process';
3-
import { Octokit } from '@octokit/core';
43
import { output } from './util.mjs';
54

65
const {
76
GITHUB_TOKEN = '',
87
PR_LIST = '',
9-
owner = 'mongodb',
10-
repo = 'js-bson'
8+
REPOSITORY = ''
119
} = process.env;
1210
if (GITHUB_TOKEN === '') throw new Error('GITHUB_TOKEN cannot be empty');
11+
if (REPOSITORY === '') throw new Error('REPOSITORY cannot be empty')
1312

14-
const octokit = new Octokit({
15-
auth: GITHUB_TOKEN,
16-
log: {
17-
debug: msg => console.error('Octokit.debug', msg),
18-
info: msg => console.error('Octokit.info', msg),
19-
warn: msg => console.error('Octokit.warn', msg),
20-
error: msg => console.error('Octokit.error', msg)
13+
const API_REQ_INFO = {
14+
headers: {
15+
Accept: 'application/vnd.github.v3+json',
16+
'X-GitHub-Api-Version': '2022-11-28',
17+
Authorization: `Bearer ${GITHUB_TOKEN}`
2118
}
22-
});
19+
}
2320

2421
const prs = PR_LIST.split(',').map(pr => {
2522
const prNum = Number(pr);
@@ -35,13 +32,10 @@ async function getPullRequestContent(pull_number) {
3532

3633
let body;
3734
try {
38-
const res = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
39-
owner,
40-
repo,
41-
pull_number,
42-
headers: { 'X-GitHub-Api-Version': '2022-11-28' }
43-
});
44-
body = res.data.body;
35+
const response = await fetch(new URL(`https://api.github.com/repos/${REPOSITORY}/pulls/${pull_number}`), API_REQ_INFO);
36+
if (!response.ok) throw new Error(await response.text());
37+
const pr = await response.json();
38+
body = pr.body;
4539
} catch (error) {
4640
console.log(`Could not get PR ${pull_number}, skipping. ${error.status}`);
4741
return '';

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
workflow_call: {}
3+
4+
name: Build
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
id-token: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- run: echo "nothing to do."
16+
shell: bash

.github/workflows/release-6.6.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
on:
2+
push:
3+
branches: ["v6.6.x"]
4+
workflow_dispatch: {}
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
id-token: write
10+
11+
name: release-6.6
12+
13+
jobs:
14+
release_please:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
release_created: ${{ steps.release.outputs.release_created }}
18+
steps:
19+
- id: release
20+
uses: googleapis/release-please-action@v4
21+
with:
22+
target-branch: "v6.6.x"
23+
24+
build:
25+
needs: [release_please]
26+
name: "Perform any build or bundling steps, as necessary."
27+
uses: ./.github/workflows/build.yml
28+
29+
ssdlc:
30+
needs: [release_please, build]
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
id-token: write
35+
contents: write
36+
environment: release
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Install Node and dependencies
42+
uses: mongodb-labs/drivers-github-tools/node/setup@v2
43+
with:
44+
ignore_install_scripts: false
45+
46+
- name: Load version and package info
47+
uses: mongodb-labs/drivers-github-tools/node/get_version_info@v2
48+
with:
49+
npm_package_name: bson
50+
51+
- name: actions/compress_sign_and_upload
52+
uses: mongodb-labs/drivers-github-tools/node/sign_node_package@v2
53+
with:
54+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
55+
aws_region_name: us-east-1
56+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
57+
npm_package_name: bson
58+
dry_run: ${{ needs.release_please.outputs.release_created == '' }}
59+
60+
- name: Copy sbom file to release assets
61+
shell: bash
62+
if: ${{ '' == '' }}
63+
run: cp sbom.json ${{ env.S3_ASSETS }}/sbom.json
64+
65+
# only used for mongodb-client-encryption
66+
- name: Augment SBOM and copy to release assets
67+
if: ${{ '' != '' }}
68+
uses: mongodb-labs/drivers-github-tools/sbom@v2
69+
with:
70+
silk_asset_group: ''
71+
sbom_file_name: sbom.json
72+
73+
- name: Generate authorized pub report
74+
uses: mongodb-labs/drivers-github-tools/full-report@v2
75+
with:
76+
release_version: ${{ env.package_version }}
77+
product_name: bson
78+
sarif_report_target_ref: "v6.6.x"
79+
third_party_dependency_tool: n/a
80+
dist_filenames: artifacts/*
81+
token: ${{ github.token }}
82+
sbom_file_name: sbom.json
83+
evergreen_project: js-bson
84+
evergreen_commit: ${{ env.commit }}
85+
86+
- uses: mongodb-labs/drivers-github-tools/upload-s3-assets@v2
87+
with:
88+
version: ${{ env.package_version }}
89+
product_name: bson
90+
dry_run: ${{ needs.release_please.outputs.release_created == '' }}
91+
92+
publish:
93+
needs: [release_please, ssdlc, build]
94+
environment: release
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Install Node and dependencies
100+
uses: mongodb-labs/drivers-github-tools/node/setup@v2
101+
102+
- run: npm publish --provenance --tag legacy
103+
if: ${{ needs.release_please.outputs.release_created }}
104+
env:
105+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
106+

.github/workflows/release_notes.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ jobs:
3939
fi
4040
4141
# checkout the HEAD ref from prNumber
42-
- uses: actions/checkout@v3
42+
- uses: actions/checkout@v4
4343
with:
4444
ref: refs/pull/${{ github.event_name == 'issue_comment' && github.event.issue.number || inputs.releasePr }}/head
4545

4646

4747
# Setup Node.js and npm install
48-
- name: actions/setup
49-
uses: ./.github/actions/setup
48+
- name: Install Node and dependencies
49+
uses: mongodb-labs/drivers-github-tools/node/setup@v2
50+
5051

5152
# See: https://github.com/googleapis/release-please/issues/1274
5253

@@ -64,6 +65,7 @@ jobs:
6465
env:
6566
GITHUB_TOKEN: ${{ github.token }}
6667
PR_LIST: ${{ steps.pr_list.outputs.pr_list }}
68+
REPOSITORY: ${{ github.repository }}
6769

6870
# The combined output is available
6971
- id: release_notes

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "6.6.0"
3+
}

release-please-config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"pull-request-title-pattern": "chore${scope}: release ${version} [skip-ci]",
4+
"pull-request-header": "Please run the release_notes action before releasing to generate release highlights",
5+
"packages": {
6+
".": {
7+
"include-component-in-tag": false,
8+
"changelog-path": "HISTORY.md",
9+
"release-type": "node",
10+
"bump-minor-pre-major": false,
11+
"bump-patch-for-minor-pre-major": false,
12+
"draft": false,
13+
"prerelease": false
14+
}
15+
}
16+
}

sbom.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"metadata": {
3+
"timestamp": "2024-05-01T20:45:06.517939+00:00",
4+
"tools": [
5+
{
6+
"externalReferences": [
7+
{
8+
"type": "build-system",
9+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions"
10+
},
11+
{
12+
"type": "distribution",
13+
"url": "https://pypi.org/project/cyclonedx-python-lib/"
14+
},
15+
{
16+
"type": "documentation",
17+
"url": "https://cyclonedx-python-library.readthedocs.io/"
18+
},
19+
{
20+
"type": "issue-tracker",
21+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues"
22+
},
23+
{
24+
"type": "license",
25+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE"
26+
},
27+
{
28+
"type": "release-notes",
29+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md"
30+
},
31+
{
32+
"type": "vcs",
33+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib"
34+
},
35+
{
36+
"type": "website",
37+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme"
38+
}
39+
],
40+
"name": "cyclonedx-python-lib",
41+
"vendor": "CycloneDX",
42+
"version": "6.4.4"
43+
}
44+
]
45+
},
46+
"serialNumber": "urn:uuid:903d1626-7841-4db5-885e-8cbad6198266",
47+
"version": 1,
48+
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
49+
"bomFormat": "CycloneDX",
50+
"specVersion": "1.5"
51+
}

0 commit comments

Comments
 (0)