Skip to content

Commit d2b828b

Browse files
authored
chore(NODE-7599): tighten build workflow permissions and update release docs (#4949)
1 parent 24e5705 commit d2b828b

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ on:
44
name: Build
55

66
permissions:
7-
contents: write
8-
pull-requests: write
9-
id-token: write
7+
contents: read
108

119
jobs:
1210
build:

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The official [MongoDB](https://www.mongodb.com/) driver for Node.js.
2222

2323
### Release Integrity
2424

25-
Releases are created automatically and signed using the [Node team's GPG key](https://pgp.mongodb.com/node-driver.asc). This applies to the git tag as well as all release packages provided as part of a GitHub release. To verify the provided packages, download the key and import it using gpg:
25+
Releases are created automatically and signed using the [Node team's GPG key](https://pgp.mongodb.com/node-driver.asc). All release packages provided as part of a GitHub release are signed. To verify the provided packages, download the key and import it using gpg:
2626

2727
```shell
2828
gpg --import node-driver.asc
@@ -46,7 +46,13 @@ gpg --verify mongodb-X.Y.Z.tgz.sig mongodb-X.Y.Z.tgz
4646
```
4747

4848
> [!Note]
49-
> No verification is done when using npm to install the package. The contents of the Github tarball and npm's tarball are identical.
49+
> No GPG verification is done when using npm to install the package. The contents of the GitHub tarball and npm's tarball are identical.
50+
51+
Releases published to the npm registry also include a [provenance attestation](https://docs.npmjs.com/generating-provenance-statements), which cryptographically links the package to its source repository and build workflow. To verify provenance:
52+
53+
```shell
54+
npm audit signatures
55+
```
5056

5157
The MongoDB Node.js driver follows [semantic versioning](https://semver.org/) for its releases.
5258

etc/notes/releasing.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,9 @@ The MongoDB driver can now generate a cup of joe.
100100

101101
### Authentication
102102

103-
The github action is able to publish with the repository secret `NPM_TOKEN`.
104-
This is a granular API key that is unique to each package and has to be rotated on a regular basis.
105-
The `dbx-node@mongodb.com` npm account is the author of the automated release.
103+
The GitHub Actions release workflow publishes to npm using [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers) (OIDC). A short-lived OIDC token is issued by GitHub Actions at publish time — no long-lived `NPM_TOKEN` secret is required on the `main` branch. The `mongodb` package's trusted publisher entry on npmjs.com points at `npm-publish.yml`, which is dispatched by `release.yml` via `dispatch-and-wait.mjs`.
106104

107-
The nightly release flow is an exception: `release-nightly.yml` dispatches
108-
`.github/workflows/npm-publish.yml`, which authenticates to the npm registry
109-
via [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers) (OIDC)
110-
rather than `NPM_TOKEN`. The `mongodb` package's trusted publisher entry on
111-
npmjs.com points at `npm-publish.yml`.
105+
The `5.x` and `6.x` backport branches still publish using the legacy `NPM_TOKEN` secret. These branches are only used when a backport release is actually needed — the migration to trusted publishers will be done at that point, not proactively.
112106

113107
### Prebuilds
114108

@@ -126,13 +120,17 @@ It may take some time for the building and uploading to finish, but no more than
126120
127121
To configure a repo for a prerelease:
128122

129-
1. Update the release Github action's `npm publish` step to publish an alpha by specifying `--tag alpha`:
123+
1. Update the release GitHub action's publish step to dispatch `npm-publish.yml` with `--tag alpha`:
130124

131125
```yaml
132-
- run: npm publish --provenance --tag alpha
133-
if: ${{ needs.release_please.outputs.release_created }}
126+
- name: Dispatch npm-publish workflow
134127
env:
135-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
128+
GH_TOKEN: ${{ github.token }}
129+
run: |
130+
node ./.github/scripts/dispatch-and-wait.mjs npm-publish.yml \
131+
tag=alpha \
132+
version="${{ inputs.alphaVersion }}" \
133+
ref="${{ github.sha }}"
136134
```
137135
138136
2. Update the release please configuration file with the following parameters:

0 commit comments

Comments
 (0)