Skip to content

Commit 78aac46

Browse files
authored
build: modfying publish action to use npm cli to include provenance in npm publish (#319)
**Requirements** - [ ] I have added test coverage for new or changed functionality - [ ] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [ ] I have validated my changes against all supported platform versions **Related issues** **Describe the solution you've provided** Yarn publish doesn't currently support NPM's publish package with provenance functionality. As a workaround until this is supported, we'll pack the workspace with yarn in order to guarantee we get the same package as before, and then use the npm cli to do the final publish with provenance. This also involves passing the workspace path as input parameters to the publish actions/script as npm's workspace functionality doesn't work exactly the same as yarns. While npm's generated provenance isn't the most robust provenance attestation, it results in a verified checkmark on the npm package page, which brings the provenance closest to the consumer and makes it most useful. **Describe alternatives you've considered** Ideally we'd want yarn to support this natively, but tracking the yarn repo issues for the past couple months has shown no movement here. **Additional context** Add any other context about the pull request here.
2 parents d975526 + a8e5337 commit 78aac46

File tree

6 files changed

+61
-3
lines changed

6 files changed

+61
-3
lines changed

.github/workflows/manual-publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
with:
4242
node-version: 16.x
4343
registry-url: 'https://registry.npmjs.org'
44+
- uses: ./actions/install-npm-version
45+
with:
46+
npm_version: 9.5.0
4447
- name: 'Setup Redis'
4548
if: ${{ inputs.workspace_path == 'packages/store/node-server-sdk-redis' }}
4649
run: |
@@ -80,5 +83,6 @@ jobs:
8083
uses: ./actions/publish
8184
with:
8285
workspace_name: ${{ env.WORKSPACE_NAME }}
86+
workspace_path: ${{ inputs.workspace_path }}
8387
prerelease: ${{ inputs.prerelease }}
8488
dry_run: ${{ inputs.dry_run }}

.github/workflows/release-please.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
with:
4141
node-version: 16.x
4242
registry-url: 'https://registry.npmjs.org'
43+
- uses: ./actions/install-npm-version
44+
with:
45+
npm_version: 9.5.0
4346
- id: release-common
4447
name: Full release of packages/shared/common
4548
uses: ./actions/full-release
@@ -60,6 +63,9 @@ jobs:
6063
with:
6164
node-version: 16.x
6265
registry-url: 'https://registry.npmjs.org'
66+
- uses: ./actions/install-npm-version
67+
with:
68+
npm_version: 9.5.0
6369
- id: release-common
6470
name: Full release of packages/shared/sdk-server
6571
uses: ./actions/full-release
@@ -80,6 +86,9 @@ jobs:
8086
with:
8187
node-version: 16.x
8288
registry-url: 'https://registry.npmjs.org'
89+
- uses: ./actions/install-npm-version
90+
with:
91+
npm_version: 9.5.0
8392
- id: release-common
8493
name: Full release of packages/shared/sdk-server-edge
8594
uses: ./actions/full-release
@@ -100,6 +109,9 @@ jobs:
100109
with:
101110
node-version: 16.x
102111
registry-url: 'https://registry.npmjs.org'
112+
- uses: ./actions/install-npm-version
113+
with:
114+
npm_version: 9.5.0
103115
- id: release-common
104116
name: Full release of packages/shared/akamai-edgeworker-sdk
105117
uses: ./actions/full-release
@@ -120,6 +132,9 @@ jobs:
120132
with:
121133
node-version: 16.x
122134
registry-url: 'https://registry.npmjs.org'
135+
- uses: ./actions/install-npm-version
136+
with:
137+
npm_version: 9.5.0
123138
- id: release-common
124139
name: Full release of packages/sdk/cloudflare
125140
uses: ./actions/full-release
@@ -140,6 +155,9 @@ jobs:
140155
with:
141156
node-version: 16.x
142157
registry-url: 'https://registry.npmjs.org'
158+
- uses: ./actions/install-npm-version
159+
with:
160+
npm_version: 9.5.0
143161
- id: release-common
144162
name: Full release of packages/sdk/server-node
145163
uses: ./actions/full-release
@@ -160,6 +178,9 @@ jobs:
160178
with:
161179
node-version: 16.x
162180
registry-url: 'https://registry.npmjs.org'
181+
- uses: ./actions/install-npm-version
182+
with:
183+
npm_version: 9.5.0
163184
- id: release-common
164185
name: Full release of packages/sdk/vercel
165186
uses: ./actions/full-release
@@ -180,6 +201,9 @@ jobs:
180201
with:
181202
node-version: 16.x
182203
registry-url: 'https://registry.npmjs.org'
204+
- uses: ./actions/install-npm-version
205+
with:
206+
npm_version: 9.5.0
183207
- id: release-common
184208
name: Full release of packages/sdk/akamai-base
185209
uses: ./actions/full-release
@@ -200,6 +224,9 @@ jobs:
200224
with:
201225
node-version: 16.x
202226
registry-url: 'https://registry.npmjs.org'
227+
- uses: ./actions/install-npm-version
228+
with:
229+
npm_version: 9.5.0
203230
- id: release-common
204231
name: Full release of packages/sdk/akamai-edgekv
205232
uses: ./actions/full-release
@@ -220,6 +247,9 @@ jobs:
220247
with:
221248
node-version: 16.x
222249
registry-url: 'https://registry.npmjs.org'
250+
- uses: ./actions/install-npm-version
251+
with:
252+
npm_version: 9.5.0
223253
- run: |
224254
sudo apt-get update
225255
sudo apt-get install redis-server
@@ -244,6 +274,9 @@ jobs:
244274
with:
245275
node-version: 16.x
246276
registry-url: 'https://registry.npmjs.org'
277+
- uses: ./actions/install-npm-version
278+
with:
279+
npm_version: 9.5.0
247280
- run: |
248281
sudo docker run -d -p 8000:8000 amazon/dynamodb-local
249282
- id: release-common

actions/full-release/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ runs:
3434
- uses: ./actions/publish
3535
with:
3636
workspace_name: ${{ env.WORKSPACE_NAME }}
37+
workspace_path: ${{ inputs.workspace_path }}
3738
prerelease: false
3839
dry_run: false
3940
- uses: ./actions/publish-docs
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Install npm version
2+
# Used to specify a version of npm that supports --provenance (for node installs < 18.X)
3+
description: Install the latest version of the npm CLI utility.
4+
inputs:
5+
npm_version:
6+
description: 'The version of npm to install'
7+
required: false
8+
default: latest
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: 'Install specified npm version'
14+
shell: bash
15+
run: |
16+
npm install -g npm@${{ inputs.npm_version }}

actions/publish/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ inputs:
44
workspace_name:
55
description: 'The workspace to publish'
66
required: true
7+
workspace_path:
8+
description: 'Path to the workspace (for npm publish)'
9+
required: true
710
prerelease:
811
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
912
required: true
@@ -21,5 +24,6 @@ runs:
2124
./scripts/publish.sh
2225
env:
2326
WORKSPACE: ${{ inputs.workspace_name }}
27+
WORKSPACE_PATH: ${{ inputs.workspace_path }}
2428
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
2529
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry_run }}

scripts/publish.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
2+
yarn workspace $WORKSPACE pack
23
if $LD_RELEASE_IS_DRYRUN ; then
34
# Dry run just pack the workspace.
45
echo "Doing a dry run of publishing."
5-
yarn workspace $WORKSPACE pack
66
else
77
if $LD_RELEASE_IS_PRERELEASE ; then
88
echo "Publishing with prerelease tag."
9-
yarn workspace $WORKSPACE npm publish --tag prerelease || { echo "npm publish failed" >&2; exit 1; }
9+
npm publish --tag prerelease --provenance --access public "./$WORKSPACE_PATH/package.tgz" || { echo "npm publish failed" >&2; exit 1; }
1010
else
11-
yarn workspace $WORKSPACE npm publish || { echo "npm publish failed" >&2; exit 1; }
11+
npm publish --provenance --access public "./$WORKSPACE_PATH/package.tgz" || { echo "npm publish failed" >&2; exit 1; }
1212
fi
1313
fi

0 commit comments

Comments
 (0)