Skip to content

Commit 90f6967

Browse files
authored
chore(NODE-7563): migrate main release workflows to npm trusted publishers (#4941)
1 parent a10d2c9 commit 90f6967

4 files changed

Lines changed: 29 additions & 128 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ jobs:
3636
ref: ${{ inputs.ref }}
3737
- name: Install Node and dependencies
3838
uses: mongodb-labs/drivers-github-tools/node/setup@v3
39-
- run: npm version "${{ inputs.version }}" --git-tag-version=false --allow-same-version
40-
- run: npm publish --provenance --tag="${{ inputs.tag }}"
39+
- run: npm version "$VERSION" --git-tag-version=false --allow-same-version
40+
env:
41+
VERSION: ${{ inputs.version }}
42+
- run: npm publish --provenance --tag="$TAG"
43+
env:
44+
TAG: ${{ inputs.tag }}

.github/workflows/release-6.8.yml

Lines changed: 0 additions & 113 deletions
This file was deleted.

.github/workflows/release-alpha.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99
type: string
1010

1111
permissions:
12-
id-token: write
12+
actions: write
13+
contents: read
1314

1415
name: release-alpha
1516

@@ -18,17 +19,22 @@ jobs:
1819
runs-on: ubuntu-latest
1920
steps:
2021
- shell: bash
22+
env:
23+
ALPHA_VERSION: ${{ inputs.alphaVersion }}
2124
run: |
2225
ALPHA_SEMVER_REGEXP="-alpha(\.([0-9]|[1-9][0-9]+))?$"
2326
24-
if ! [[ "${{ inputs.alphaVersion }}" =~ $ALPHA_SEMVER_REGEXP ]]; then
27+
if ! [[ "$ALPHA_VERSION" =~ $ALPHA_SEMVER_REGEXP ]]; then
2528
echo "Invalid alphaVersion string"
2629
exit 1
2730
fi
2831
- uses: actions/checkout@v5
29-
- name: Install Node and dependencies
30-
uses: mongodb-labs/drivers-github-tools/node/setup@v3
31-
- run: npm version "${{ inputs.alphaVersion }}" --git-tag-version=false
32-
- run: npm publish --provenance --tag=alpha
32+
- name: Dispatch npm-publish workflow
3333
env:
34-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34+
GH_TOKEN: ${{ github.token }}
35+
ALPHA_VERSION: ${{ inputs.alphaVersion }}
36+
run: |
37+
node ./.github/scripts/dispatch-and-wait.mjs npm-publish.yml \
38+
tag=alpha \
39+
version="$ALPHA_VERSION" \
40+
ref="${{ github.sha }}"

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
permissions:
77
contents: write
88
pull-requests: write
9-
id-token: write
109

1110
name: release-latest
1211

@@ -91,15 +90,20 @@ jobs:
9190

9291
publish:
9392
needs: [release_please, ssdlc, build]
93+
permissions:
94+
actions: write
95+
contents: read
9496
environment: release
9597
runs-on: ubuntu-latest
9698
steps:
9799
- uses: actions/checkout@v5
98100

99-
- name: Install Node and dependencies
100-
uses: mongodb-labs/drivers-github-tools/node/setup@v3
101-
102-
- run: npm publish --provenance --tag=latest
101+
- name: Dispatch npm-publish workflow
103102
if: ${{ needs.release_please.outputs.release_created }}
104103
env:
105-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
104+
GH_TOKEN: ${{ github.token }}
105+
run: |
106+
node ./.github/scripts/dispatch-and-wait.mjs npm-publish.yml \
107+
tag=latest \
108+
version="$(node -p "require('./package.json').version")" \
109+
ref="${{ github.sha }}"

0 commit comments

Comments
 (0)