-
Notifications
You must be signed in to change notification settings - Fork 13
fix(ci): sync Cargo.toml version before native binary build #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ada002f
c43a2e4
ff3e76a
d526cc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -93,7 +93,7 @@ jobs: | |||||||||||||||||||||||||||||||||||
| echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| build-native: | ||||||||||||||||||||||||||||||||||||
| needs: preflight | ||||||||||||||||||||||||||||||||||||
| needs: [preflight, compute-version] | ||||||||||||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||||||||||||
|
|
@@ -177,6 +177,16 @@ jobs: | |||||||||||||||||||||||||||||||||||
| sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so" | ||||||||||||||||||||||||||||||||||||
| sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so.1" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| - name: Sync Cargo.toml version | ||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||
| VERSION: ${{ needs.compute-version.outputs.version }} | ||||||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||
| [[ -n "$VERSION" ]] || { echo "::error::VERSION is empty — compute-version output missing"; exit 1; } | ||||||||||||||||||||||||||||||||||||
| CARGO="crates/codegraph-core/Cargo.toml" | ||||||||||||||||||||||||||||||||||||
| awk -v v="$VERSION" '!done && /^version =/{$0="version = \""v"\""; done=1}1' "$CARGO" > "${CARGO}.tmp" | ||||||||||||||||||||||||||||||||||||
| mv "${CARGO}.tmp" "$CARGO" | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+180
to
+188
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If A one-line guard at the top of the
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in c43a2e4. Added a guard at the top of the [[ -n "$VERSION" ]] || { echo "::error::VERSION is empty — compute-version output missing"; exit 1; }The workflow will now fail immediately with a clear GitHub Actions error annotation if |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| - name: Install napi-rs CLI | ||||||||||||||||||||||||||||||||||||
| run: npm install -g @napi-rs/cli@3 | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awkreplaces all^version =lines, not just the[package]versionThe pattern
/^version =/is a "replace all" inawk(every matching line is rewritten). Currentlycrates/codegraph-core/Cargo.tomlonly has one such line so this works, but it would silently corrupt the file the moment a second top-levelversion = …appears (e.g. a workspace[package.metadata]block, a feature-flag version, etc.).Compare this with
scripts/sync-native-versions.js, which uses a first-match-only replace (nogflag on the regex). For consistency and safety, scope the replacement to the first occurrence only:Alternatively, using
awkwith an early-exit flag after the first replacement:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ff3e76a. Added an early-exit flag to the
awkcommand so only the first^version =line is replaced:This matches the first-occurrence-only behavior of
scripts/sync-native-versions.jsand prevents corruption if a secondversion =line appears in a different TOML section.