Skip to content

Commit 7d9026e

Browse files
chore: update Release workflow to use OIDC
1 parent 35d700c commit 7d9026e

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,39 @@ on:
77
- main
88

99
jobs:
10-
release:
11-
uses: finsweet/workflow-release/.github/workflows/release.yml@main
12-
secrets:
13-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
10+
Release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: write
16+
pull-requests: write
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup pnpm
24+
uses: pnpm/action-setup@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 24
30+
cache: pnpm
31+
32+
- name: Install Dependencies
33+
run: pnpm install --frozen-lockfile
34+
35+
- name: Build Project
36+
run: pnpm build
37+
38+
- name: Create Release Pull Request and Publish to npm
39+
id: changesets-production
40+
uses: changesets/action@v1
41+
with:
42+
publish: pnpm release
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
NPM_CONFIG_PROVENANCE: true

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ You'll be prompted with a few questions to complete the changelog.
223223
Once the Pull Request is merged into `master`, a new Pull Request will automatically be opened by a changesets bot that bumps the package version and updates the `CHANGELOG.md` file.
224224
You'll have to manually merge this new PR to complete the workflow.
225225

226-
If an `NPM_TOKEN` secret is included in the repository secrets, Changesets will automatically deploy the new package version to npm.
226+
You can set up Changesets to automatically deploy the new package version to npm.
227227
See [how to automatically deploy updates to npm](#how-to-automatically-deploy-updates-to-npm) for more info.
228228

229229
#### How to enable Continuous Deployment with Changesets
@@ -239,13 +239,8 @@ Enabling this setting for your organization account (`Account Settings > Actions
239239

240240
#### How to automatically deploy updates to npm
241241

242-
As mentioned before, Changesets will automatically deploy the new package version to npm if an `NPM_TOKEN` secret is provided.
242+
The `Release` GitHub Action uses OpenID Connect to authenticate with npm, allowing automatic deployments without the need to store any secret in your repository.
243243

244-
This npm token should be:
244+
To enable deployments to npm, [configure the GitHub repository as a Trusted Publisher](https://docs.npmjs.com/trusted-publishers) and Changesets will take care of the rest.
245245

246-
- From Finsweet's npm organization if this repository is meant for internal/product development.
247-
- From a client's npm organization if this repository is meant for client development. In this case, you should ask the client to [create an npm account](https://www.npmjs.com/signup) and provide you the credentials (or the npm token, if they know how to get it).
248-
249-
Once you're logged into the npm account, you can get an access token by following [this guide](https://docs.npmjs.com/creating-and-viewing-access-tokens).
250-
251-
The access token must be then placed in a [repository secret](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/managing-encrypted-secrets-for-your-repository-and-organization-for-codespaces#adding-secrets-for-a-repository) named `NPM_TOKEN`.
246+
If this is the first time deploying to npm from this repository, you might need to [manually publish the first version of the package](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages#publishing-scoped-public-packages).

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,8 @@
5656
},
5757
"engines": {
5858
"pnpm": ">=10"
59+
},
60+
"publishConfig": {
61+
"provenance": true
5962
}
6063
}

0 commit comments

Comments
 (0)