fix(ci): set versions from one script in both publish paths - #9
Merged
Merged
Conversation
The semantic-release path and the manual workflow each carried their own version-bump logic, and they had drifted apart: - the manual path never re-pointed the internal @dorval/core dependency, so a manually published CLI kept whatever range it had before; - `npm version <same version>` fails with "Version not changed", which is exactly what the manual path needs to do when recovering a release that published some packages and not others; - the semantic-release sed only rewrote packages/dorval, leaving the @dorval/core range in dio and custom untouched - both still declare "*". scripts/version.js already did all of this, but it was dead code: it used require() under "type": "module", so it threw on every run, and the `yarn version:update` script pointing at it was broken too. Ported it to ESM, made it re-point every internal dependency rather than one file, and pointed both publish paths at it. Setting a version that is already set is now a no-op rather than an error, so re-publishing to finish a half-done release works.
…ed files The v0.10.7 manual publish ran `npm version` at the repo root, which generated a package-lock.json, and the following `git add .` swept it into main. turbo then refuses to start: x could not resolve workspaces: We detected multiple package managers in | your repository: npm, yarn. Please remove one of them. which fails every CI job at the build step. The same commit also rewrote yarn.lock, dropping ~470 entries. Removes the lockfile, restores yarn.lock to its state before that publish, and ignores package-lock.json so a stray one cannot come back. The commit step now stages only the files the version step touches instead of everything in the tree. Combined with replacing `npm version` with scripts/version.js, which writes nothing but package.json files, neither half of the original failure can recur.
Contributor
|
🎉 This PR is included in version 0.10.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update: this also unbreaks
mainmainis currently red on every job. The v0.10.7 manual publish rannpm versionat the repo root, which generated apackage-lock.json, and thegit add .in the next step swept it intomainalong with a rewrittenyarn.lock:turbo then refuses to start, so the build step fails everywhere:
The second commit removes the lockfile, restores
yarn.lockto its state before that publish, ignorespackage-lock.json, and narrows the commit step to stage only the files the version step touches rather than the whole tree.That closes both halves of the failure:
scripts/version.jswrites nothing butpackage.jsonfiles, so no lockfile is generated in the first place, and the commit step would not pick one up even if something else created it.Verified locally:
yarn install --frozen-lockfileandyarn buildboth succeed, 450 tests pass, and both workflow files still parse.Problem
Version bumping was implemented twice, once per publish path, and the two had drifted.
The manual workflow never re-pointed the internal dependency. It ran
npm versionper package and stopped there, while.releaserc.jsonadditionally rewrote the@dorval/corerange. The v0.10.7 release went out through the manual workflow, so:Harmless this time —
^0.10.6still satisfies 0.10.7 — but a manual release crossing a minor boundary would ship a CLI resolving to an older core.npm versionrefuses to set the version it already has. Recovering a half-published release means re-running with the same version, which is precisely what the manual workflow cannot do:That is why v0.10.6 could not be finished through the manual workflow after the CLI failed to publish; the run would have died before reaching the publish step.
The sed only ever covered one file. It rewrote
packages/dorval/package.json, so the@dorval/corerange indioandcustomwas never touched — both still declare"*"today, on every published version:A wildcard on your own core package means
npm i @dorval/dioresolves whatever is newest, including a future incompatible major.Change
scripts/version.jsalready did all of this — set every package's version, root included, and re-point internal@dorval/*dependencies. It was dead code: it usedrequire()under"type": "module", so it threwReferenceError: require is not definedon every run, which also means theyarn version:updatescript pointing at it has never worked.Ported it to ESM, changed it to re-point internal dependencies in every package rather than one file via sed, and pointed both publish paths at it:
The range stays a caret, matching what published packages already carry.
dioandcustommove from"*"to^<version>on the next release — called out because it changes their published metadata, and is the point of the fix rather than a side effect.This is the same consolidation #8 did for publishing: one implementation, both callers.
Verification
npm versionfails the second time. This is what makes recovery re-runs work.versionand@dorval/*dependency lines — no reformatting,package.jsonfiles are already 2-space.{"name": "Update versions in all packages", "run": "node scripts/version.js ${{ inputs.version }}"}..releaserc.jsonis still valid JSON and the surrounding formatting is untouched (one line changed).Not in this PR
scripts/sync-versions.jsis a third partial implementation — it syncs packages from the root version but does not re-point dependencies, andyarn version:syncstill points at it. It works, so nothing is broken today, but it is the same drift risk this PR removes elsewhere. Worth deleting separately once no one relies on it.