You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/rules/versioning-with-npm.mdc
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ You are an expert release manager for a Yarn 4 monorepo who uses the npm CLI for
8
8
- Treat new components and minor fixes as patch releases when they are additive and low-risk.
9
9
- Reserve minor/major only for notable feature waves or breaking changes.
10
10
11
-
Note: While the repo supports Changesets for broader release coordination, this rule documents the npm CLI flow for quick iterations.
11
+
Note: The primary release workflow uses Changesets (`yarn changeset` → `yarn changeset version` → automatic CI/CD publish). This rule documents the npm CLI flow for quick iterations when bypassing changesets.
12
12
13
13
## What Counts As “Small”
14
14
- Additive components (new UI or form wrappers) without breaking changes
@@ -47,7 +47,8 @@ Guidelines:
47
47
48
48
## Open PR and Merge
49
49
- Push your branch and open a PR.
50
-
- When the PR merges into `main`, GitHub CI publishes the package. No manual tagging or `npm publish` needed.
50
+
- When the PR merges into `main`, GitHub CI automatically publishes the package using npm trusted publishers (OIDC). No manual tagging or `npm publish` needed, and no npm tokens required.
51
+
- **Note:** The release workflow uses [npm trusted publishers](https://docs.npmjs.com/trusted-publishers) for secure, tokenless publishing. Ensure the trusted publisher is configured on npmjs.com for the package.
51
52
52
53
## Minor / Major (When Needed)
53
54
- Minor: larger feature sets or notable additions across multiple components
- Versioning: when changing published package(s), add a Changeset (`yarn changeset`) before merge.
39
+
- Publishing: Releases are automatically published via CI/CD using [npm trusted publishers](https://docs.npmjs.com/trusted-publishers) (OIDC). No npm tokens required. See README.md for setup instructions.
39
40
40
41
## Security & Configuration
41
42
- Node `22.9.0` (`.nvmrc`) and Yarn 4 (`packageManager`).
42
43
- Do not commit secrets. Keep large artifacts out of VCS (`dist`, `node_modules`).
Copy file name to clipboardExpand all lines: README.md
+131Lines changed: 131 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,3 +128,134 @@ The PR preview is deployed to the `gh-pages` branch in a directory structure lik
128
128
```
129
129
/pr-preview/pr-[PR_NUMBER]/
130
130
```
131
+
132
+
## Publishing
133
+
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.
158
+
159
+
### Prerequisites
160
+
161
+
1.**Ensure you're logged into npm:**
162
+
```bash
163
+
npm login
164
+
```
165
+
You must be logged in as a user with publish permissions for the `@lambdacurry` organization.
166
+
167
+
2.**Verify your npm credentials:**
168
+
```bash
169
+
npm whoami
170
+
```
171
+
172
+
3.**Ensure you're on the `main` branch and up to date:**
173
+
```bash
174
+
git checkout main
175
+
git pull origin main
176
+
```
177
+
178
+
### Release Process
179
+
180
+
#### Step 1: Create Changesets (if needed)
181
+
182
+
If you have changes that need to be documented in the changelog, create a changeset:
183
+
184
+
```bash
185
+
yarn changeset
186
+
```
187
+
188
+
Follow the prompts to:
189
+
- Select which packages to include
190
+
- Choose the version bump type (patch, minor, major)
191
+
- Write a summary of the changes
192
+
193
+
#### Step 2: Version Packages
194
+
195
+
This updates package versions and generates the changelog:
196
+
197
+
```bash
198
+
yarn changeset version
199
+
```
200
+
201
+
This will:
202
+
- Update `packages/components/package.json` with the new version
203
+
- Update `packages/components/CHANGELOG.md` with the new entries
204
+
- Remove the consumed changeset files
205
+
206
+
#### Step 3: Build and Test
207
+
208
+
Before publishing, ensure everything builds and tests pass:
209
+
210
+
```bash
211
+
yarn build
212
+
yarn test
213
+
```
214
+
215
+
#### Step 4: Publish to npm
216
+
217
+
Publish the package to npm using changesets:
218
+
219
+
```bash
220
+
yarn release
221
+
```
222
+
223
+
This command runs `changeset publish`, which:
224
+
- Runs `yarn build` (via `prepublishOnly` hook in package.json)
225
+
- Publishes `@lambdacurry/forms` to npm (uses npm under the hood)
226
+
- Creates git tags for the release
227
+
- Requires you to be logged into npm (`npm login`)
228
+
229
+
**Note:**`changeset publish` uses npm CLI internally, so you must be authenticated with npm. The changeset system handles versioning, changelog generation, and publishing all in one workflow.
230
+
231
+
#### Step 5: Commit and Push
232
+
233
+
After successful publishing, commit the version changes and push:
234
+
235
+
```bash
236
+
git add .
237
+
git commit -m "chore(release): publish vX.Y.Z"
238
+
git push origin main
239
+
```
240
+
241
+
### Alternative: Direct npm Publish (Without Changesets)
242
+
243
+
If you need to publish without using changesets (e.g., for a hotfix), you can use npm directly:
244
+
245
+
```bash
246
+
# From the packages/components directory
247
+
cd packages/components
248
+
npm version patch -m "chore: bump version to %s"
249
+
cd ../..
250
+
yarn install # Update yarn.lock
251
+
yarn workspace @lambdacurry/forms build
252
+
npm publish --workspace=packages/components
253
+
```
254
+
255
+
**Note:** This bypasses the changeset workflow, so you'll need to manually update the CHANGELOG.md if you want to document the release.
256
+
257
+
### Troubleshooting
258
+
259
+
-**"Not logged in" error**: Run `npm login` and verify with `npm whoami`
260
+
-**"Permission denied"**: Ensure your npm user has publish permissions for `@lambdacurry` organization
261
+
-**Build fails**: Fix build errors before publishing. The `prepublishOnly` hook will prevent publishing if the build fails
0 commit comments