Skip to content

Commit b320a1b

Browse files
authored
Merge pull request #1588 from Adyen/copilot/fix-unsafe-package-publishing
Secure NPM publishing workflow against supply chain attacks
2 parents 210cfad + 1f15d9a commit b320a1b

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

.github/workflows/npmpublish.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,44 @@ permissions:
1111
contents: read
1212

1313
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
19+
with:
20+
node-version: '18.x'
21+
- name: Install dependencies
22+
run: yarn install --frozen-lockfile
23+
- name: Build package
24+
run: npm run build
25+
- name: Run tests
26+
run: npm run test
27+
- name: Upload build artifact
28+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
29+
with:
30+
name: build-output
31+
path: lib/
32+
retention-days: 1
33+
1434
publish-npm:
1535
runs-on: ubuntu-latest
36+
needs: build
1637
environment: release
17-
env:
18-
NODE_AUTH_TOKEN: ${{ secrets.NPM_ADYEN_NODE_API_LIBRARY_TOKEN }}
1938
steps:
2039
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2140
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
2241
with:
2342
node-version: '18.x'
2443
registry-url: 'https://registry.npmjs.org'
2544
always-auth: true
26-
- run: |
27-
npm install
28-
npm run build
29-
- run: npm publish
45+
- name: Download build artifact
46+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
47+
with:
48+
name: build-output
49+
path: lib/
50+
- name: Publish to NPM
51+
run: npm publish
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ADYEN_NODE_API_LIBRARY_TOKEN }}
3054

0 commit comments

Comments
 (0)