Skip to content

Commit 193ed00

Browse files
authored
ci: Enable NPM publishing with OIDC (#313)
* Enable NPM publishing with OIDC * Remove another instance of `SKIP_PREPACK` * Pin `fflate` to `0.8.2` * Remove prepack script * Restore prepack script * Fix version * Fix prepack script permissions * Bump Yarn version
1 parent 8efaf35 commit 193ed00

5 files changed

Lines changed: 20 additions & 11 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ jobs:
117117
name: Publish release
118118
permissions:
119119
contents: write
120+
id-token: write
120121
uses: ./.github/workflows/publish-release.yml
121122
secrets:
122123
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/publish-release.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
secrets:
66
NPM_TOKEN:
7-
required: true
7+
required: false
88
SLACK_WEBHOOK_URL:
99
required: true
1010
PUBLISH_DOCS_TOKEN:
@@ -50,8 +50,7 @@ jobs:
5050
with:
5151
name: publish-release-artifacts-${{ github.sha }}
5252
- name: Dry Run Publish
53-
# omit npm-token token to perform dry run publish
54-
uses: MetaMask/action-npm-publish@v5
53+
uses: MetaMask/action-npm-publish@v6
5554
with:
5655
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
5756
subteam: S042S7RE4AE # @metamask-npm-publishers
@@ -63,6 +62,9 @@ jobs:
6362
needs: publish-npm-dry-run
6463
runs-on: ubuntu-latest
6564
environment: npm-publish
65+
permissions:
66+
contents: read
67+
id-token: write
6668
steps:
6769
- name: Checkout and setup environment
6870
uses: MetaMask/action-checkout-and-setup@v3
@@ -74,10 +76,13 @@ jobs:
7476
with:
7577
name: publish-release-artifacts-${{ github.sha }}
7678
- name: Publish
77-
uses: MetaMask/action-npm-publish@v5
79+
uses: MetaMask/action-npm-publish@v6
7880
with:
79-
# This `NPM_TOKEN` needs to be manually set per-repository.
80-
# Look in the repository settings under "Environments", and set this token in the `npm-publish` environment.
81+
# This `NPM_TOKEN` needs to be manually set to publish a package for
82+
# the first time only.
83+
# Look in the repository settings under "Environments", and set this
84+
# token in the `npm-publish` environment, and delete it after the
85+
# initial publish.
8186
npm-token: ${{ secrets.NPM_TOKEN }}
8287
env:
8388
SKIP_PREPACK: true

.yarnrc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ logFilters:
1515
- code: YN0004
1616
level: discard
1717

18+
nodeLinker: node-modules
19+
1820
# Configure the NPM minimal age gate to 3 days, meaning packages must be at
1921
# least 3 days old to be installed.
2022
npmMinimalAgeGate: 4320 # 3 days (in minutes)
@@ -26,8 +28,6 @@ npmPreapprovedPackages:
2628
- '@metamask-previews/*'
2729
- '@lavamoat/*'
2830

29-
nodeLinker: node-modules
30-
3131
plugins:
3232
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
3333
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@
8181
"vite": "^8.0.8",
8282
"vitest": "^4.1.4"
8383
},
84+
"resolutions": {
85+
"fflate": "0.8.2"
86+
},
8487
"engines": {
8588
"node": "^20 || ^22 || >=24"
8689
},
87-
"packageManager": "yarn@4.14.1",
90+
"packageManager": "yarn@4.16.0",
8891
"lavamoat": {
8992
"allowScripts": {
9093
"@lavamoat/preinstall-always-fail": false,

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Manual changes might be lost - proceed with caution!
33

44
__metadata:
5-
version: 9
5+
version: 10
66
cacheKey: 10
77

88
"@aashutoshrathi/word-wrap@npm:^1.2.3":
@@ -3163,7 +3163,7 @@ __metadata:
31633163
languageName: node
31643164
linkType: hard
31653165

3166-
"fflate@npm:^0.8.2":
3166+
"fflate@npm:0.8.2":
31673167
version: 0.8.2
31683168
resolution: "fflate@npm:0.8.2"
31693169
checksum: 10/2bd26ba6d235d428de793c6a0cd1aaa96a06269ebd4e21b46c8fd1bd136abc631acf27e188d47c3936db090bf3e1ede11d15ce9eae9bffdc4bfe1b9dc66ca9cb

0 commit comments

Comments
 (0)