Skip to content

Commit f8916bc

Browse files
committed
feat: add CI/CD release workflow with npm trusted publishers
- Recreate release.yml workflow with OIDC support - Add id-token: write permission for trusted publishing - Update README with trusted publisher setup instructions - Remove need for NPM_TOKEN secret
1 parent 8debc2d commit f8916bc

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
permissions:
11+
id-token: write # Required for OIDC trusted publishing
12+
contents: read
13+
14+
jobs:
15+
release:
16+
name: Release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '22'
26+
registry-url: 'https://registry.npmjs.org'
27+
28+
- name: Enable Corepack
29+
run: corepack enable
30+
31+
- name: Install Correct Yarn Version
32+
run: corepack prepare yarn@4.9.1 --activate
33+
34+
- name: Install Dependencies
35+
run: yarn install --immutable
36+
37+
- name: Create Release Pull Request or Publish to npm
38+
id: changesets
39+
uses: changesets/action@v1
40+
with:
41+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
42+
publish: yarn release
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
# No NPM_TOKEN needed - using trusted publishing via OIDC

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,30 @@ The PR preview is deployed to the `gh-pages` branch in a directory structure lik
131131

132132
## Publishing
133133

134-
Releases are published manually from the command line. This ensures full control over the release process and avoids CI/CD token management issues.
134+
Releases can be published either automatically via CI/CD (using npm trusted publishers) or manually from the command line.
135+
136+
### Automatic Publishing (CI/CD)
137+
138+
When you merge changes to `main` with version updates, the GitHub Actions workflow will automatically publish to npm using [npm trusted publishers](https://docs.npmjs.com/trusted-publishers). This uses OIDC authentication and doesn't require npm tokens.
139+
140+
**Setup required:** Configure trusted publishers on npmjs.com for the `@lambdacurry/forms` package (see setup instructions below).
141+
142+
#### Setting Up Trusted Publishers
143+
144+
1. Go to your package on npmjs.com: https://www.npmjs.com/package/@lambdacurry/forms
145+
2. Navigate to **Settings****Trusted Publisher** section
146+
3. Click **"Select your publisher"****GitHub Actions**
147+
4. Configure the following:
148+
- **Organization or user**: `lambda-curry` (or your GitHub username)
149+
- **Repository**: `forms`
150+
- **Workflow filename**: `release.yml` (must match exactly, including `.yml` extension)
151+
5. Click **Save**
152+
153+
The workflow file must exist at `.github/workflows/release.yml` in your repository. Once configured, publishes from the `main` branch will use OIDC authentication automatically.
154+
155+
### Manual Publishing
156+
157+
You can also publish manually from the command line when needed.
135158

136159
### Prerequisites
137160

0 commit comments

Comments
 (0)