Skip to content

Commit d431cd1

Browse files
authored
fix(release): remove version script that caused recursive lerna invocation (#142)
The version script in package.json was triggered as a lifecycle hook during `lerna version`, causing a recursive call that failed with EUNCOMMIT error. Removed conflicting npm scripts (version, publish, release) and updated documentation to reference workflow source files. Introduced in #135.
1 parent fcaf40a commit d431cd1

3 files changed

Lines changed: 39 additions & 47 deletions

File tree

docs/PUBLISHING-SETUP.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Check that workflow can authenticate:
5555
To publish packages manually from local machine:
5656

5757
1. **Environment Variables**:
58-
- `NPM_TOKEN` - For npm authentication
58+
- `NPM_TOKEN` - For npm authentication (or `NODE_AUTH_TOKEN`)
5959
- `GH_TOKEN` - For creating GitHub releases
6060

6161
2. **Clean Working Tree**: No uncommitted changes
@@ -64,7 +64,30 @@ To publish packages manually from local machine:
6464

6565
4. **Tests Passing**: Run `npm test`
6666

67-
See: docs/agents/release.md for manual release workflow
67+
### Manual Release Commands
68+
69+
Execute these commands in order:
70+
71+
```bash
72+
# Set npm authentication (use NPM_TOKEN from environment)
73+
npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
74+
75+
# Build packages
76+
npm run build
77+
78+
# Run tests
79+
npm run test
80+
81+
# Version packages (creates git tags and GitHub releases)
82+
npx lerna version --yes --no-private
83+
84+
# Publish to npm
85+
npx lerna publish from-git --yes --no-private
86+
```
87+
88+
**Important**: Do NOT create npm scripts named `version` or `publish` - these names conflict with npm lifecycle hooks and cause recursive execution issues.
89+
90+
See: docs/agents/release.md for more details on the release workflow
6891

6992
## Troubleshooting
7093

docs/agents/release.md

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,15 @@ Publishing packages to npm using Lerna-Lite with conventional commits.
1010

1111
### Production Releases
1212

13-
Automatically triggered on:
13+
Auto-triggered on push to main. Skipped when commit starts with `chore(release):` or no package changes.
1414

15-
- Push to main branch (after PR merge)
15+
### Pre-release (Feature Branch)
1616

17-
Releases are SKIPPED when:
18-
19-
- Commit message starts with `chore(release):`
20-
- No packages have changed since last release
21-
- Only test/doc/config files changed (see lerna.json ignoreChanges)
22-
23-
### Feature Branch Releases (Pre-release)
24-
25-
Manually triggered via GitHub Actions workflow_dispatch.
26-
27-
Results:
28-
29-
- Pre-release version (e.g., `0.1.0-beta.0`)
30-
- Custom dist-tag (auto-generated from branch name or specified)
31-
- NO git tags or GitHub releases
32-
- Does NOT affect `latest` npm dist-tag
33-
34-
**Note**: Pre-release version changes are NOT committed back to the branch. Each manual trigger increments the pre-release counter (`.0`, `.1`, `.2`, etc.).
17+
Manual workflow_dispatch trigger. Creates pre-release version with custom dist-tag. NO git tags. Version changes NOT committed to branch.
3518

3619
### Pre-release Cleanup
3720

38-
When a PR is closed or merged, the cleanup workflow automatically:
39-
40-
- Removes the dist-tag from npm (e.g., `beta`, `feat-xyz`)
41-
- Leaves published versions in npm (doesn't break existing users)
42-
- Users can still install by exact version: `npm install @pkg@0.1.0-beta.0`
43-
44-
The dist-tag removal prevents new installations via `npm install @pkg@beta` while keeping the version available for existing users.
21+
Auto-removes dist-tag when PR closed/merged. Published versions remain available.
4522

4623
## Version Bumping
4724

@@ -59,25 +36,20 @@ Conventional commit types determine version bump:
5936

6037
### Production Release
6138

62-
Automatic on push to main (after PR merge). No manual action needed.
63-
64-
### Pre-release (Feature Branch Testing)
39+
Automatic on push to main. No action needed.
6540

66-
Trigger manually via workflow_dispatch. Pre-release publishes to custom dist-tag.
41+
### Pre-release (Feature Branch)
6742

68-
Requires maintain or admin repository access.
69-
70-
Options:
71-
72-
- Empty dist-tag input: auto-generates from branch name
73-
- Specified dist-tag: uses provided value (must be valid npm dist-tag format)
74-
- Dry-run: validates without publishing
43+
Manual workflow_dispatch. Requires maintain/admin access. Dist-tag auto-generated from branch or specified.
7544

7645
### Manual/Emergency Release
7746

78-
For local releases when automation unavailable: build → test → version → publish
47+
NEVER use npm scripts named `version` or `publish` - they conflict with npm lifecycle hooks.
48+
49+
Use npx lerna commands directly with `--yes` and `--no-private` flags.
7950

80-
See: `.github/workflows/release.yml` for workflow implementation
81-
See: `docs/PUBLISHING-SETUP.md` for first-time configuration and manual release setup
51+
See: `.github/workflows/release.yml` lines 172-173, 249 for production commands
52+
See: `.github/workflows/release.yml` lines 192-197, 271-276 for pre-release commands
53+
See: `docs/PUBLISHING-SETUP.md` for complete manual release procedure
8254
See: `lerna.json` for Lerna configuration
8355
See: `docs/agents/git.md` for commit message format

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
"test": "jest --coverage",
4141
"test:watch": "jest --watch",
4242
"test:ci": "jest --ci --coverage --maxWorkers=2",
43-
"prepare": "husky",
44-
"version": "lerna version --no-private",
45-
"publish": "lerna publish from-git --no-private",
46-
"release": "npm run build && npm run test && npm run version && npm run publish"
43+
"prepare": "husky"
4744
},
4845
"devDependencies": {
4946
"@lerna-lite/cli": "^4.10.3",

0 commit comments

Comments
 (0)