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
🤖 Fix npm publish workflow to skip existing versions (#365)
## Problem
The npm publish workflow on `main` has been failing with:
```
npm error 404 '@coder/[email protected]' is not in this registry.
```
This error is misleading. The actual issue is:
- The workflow runs on **every push to main**
- It tries to publish version `0.3.0` every time
- npm doesn't allow republishing the same version
- The 404 error is npm's confusing way of saying "this version already
exists"
## Solution
Use `git describe` to generate **unique pre-release versions** for each
commit to main. This allows every push to be publishable without version
conflicts.
### Version Format
**On main branch (pre-releases):**
```
0.3.0-next.14.g6c0e10d
└─┬─┘ └─┬─┘ └┬┘ └──┬──┘
│ │ │ └─ short git hash
│ │ └─────── commits since last tag
│ └──────────── pre-release identifier
└────────────────── base version from package.json
```
Published to npm with `next` tag: `npm install @coder/cmux@next`
**On version tags (stable releases):**
```
0.3.0
```
Published to npm with `latest` tag: `npm install @coder/cmux`
## How It Works
1. **Generate unique version**: Calculate commits since last tag + git
hash
2. **Update package.json**: Modify version before building
3. **Build**: Run `make build` with the updated version
4. **Check if version exists**: See if this exact version is already on
npm
5. **Publish or promote**:
- New version → Publish normally
- Existing version + tag push → Update dist-tag to `latest` (promotion)
- Existing version + main push → Skip (already published)
### Handling Version Promotion
If a tagged release (e.g., `v0.3.0`) is pushed but `0.3.0` already
exists on npm (maybe published as a pre-release or from a previous run),
the workflow will **update the dist-tag** to `latest` instead of
failing. This allows promoting versions without re-uploading the
tarball.
Every commit to main now gets a unique, installable pre-release version!
🎉
_Generated with `cmux`_
0 commit comments