fix(ci): replace sed version bump with npm version to prevent script corruption#125
Open
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Open
fix(ci): replace sed version bump with npm version to prevent script corruption#125Kyzgor wants to merge 1 commit intopermitio:mainfrom
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Conversation
…corruption The CI workflow used `sed -i "s/\"version\": \".*\"/.../"` to bump the version in package.json before publishing. This greedy regex matched every `"version": "..."` pattern in the file, including the `version` script in the `scripts` block, corrupting it from `"standard-version"` to the release version string. Replace sed with `npm version --no-git-tag-version --allow-same-version` which safely modifies only the top-level `version` field. Also restore the corrupted `version` script to its original value. Fixes permitio#89
fb9c66a to
a14220b
Compare
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.
Summary
Replace the greedy
sedregex in the CI publish workflow withnpm version, and restore the corruptedversionscript in package.json.Problem
The CI workflow (node_sdk_publish.yaml) uses
sed -i "s/\"version\": \".*\"/.../"to bump the version before publishing. This regex matches every"version": "..."pattern in package.json — not just the top-levelversionfield, but also theversionscript insidescripts.This caused the
versionscript to be silently corrupted from"standard-version"to the release version string (e.g.,"2.5.2"). The corruption was introduced in commit2abe31fand has persisted since.Solution
sedwithnpm version "$TAG" --no-git-tag-version --allow-same-version --ignore-scripts, which safely modifies only the top-levelversionfield via npm's JSON-aware tooling--no-git-tag-versionprevents npm from creating a git commit and tag--ignore-scriptsprevents theversionlifecycle script (standard-version) from running during the CI bumpversionscript in package.json from the corrupted"2.5.2"back to its original value:"standard-version"Changes
.github/workflows/node_sdk_publish.yaml— replaced sed command withnpm versionpackage.json— restoredscripts.versionfrom"2.5.2"to"standard-version"Testing
Verified locally that
npm version "X.Y.Z" --no-git-tag-version --allow-same-version --ignore-scripts:versionfieldscripts.versionBackwards Compatibility
No breaking changes. The
npm versioncommand produces the same result (updatedversionfield) without the side effect of corrupting other fields.Fixes #89