Skip to content

Commit ffb628c

Browse files
authored
fix(ci): sync Cargo.toml version before native binary build (#538)
* fix(ci): sync Cargo.toml version before native binary build The build-native job ran in parallel with compute-version, so the Rust crate was compiled with whatever stale version was in Cargo.toml rather than the release version. This caused `codegraph info` to report "binary built as 3.2.0" even on a 3.3.0 release. Make build-native depend on compute-version and update Cargo.toml before `cargo build` so env!("CARGO_PKG_VERSION") returns the correct version. * fix: guard against empty VERSION in Cargo.toml sync step (#538) Add validation that $VERSION is non-empty before writing to Cargo.toml. Prevents silently writing an empty version string if compute-version output is missing. * fix: scope awk version replacement to first occurrence only (#538) Use an early-exit flag so only the first ^version = line in Cargo.toml is replaced. Prevents silently corrupting the file if a second version = line appears in a different TOML section.
1 parent 8e78e62 commit ffb628c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT"
9494
9595
build-native:
96-
needs: preflight
96+
needs: [preflight, compute-version]
9797
strategy:
9898
fail-fast: false
9999
matrix:
@@ -177,6 +177,16 @@ jobs:
177177
sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so"
178178
sudo ln -sf /lib/x86_64-linux-gnu/libgcc_s.so.1 "${GNU_LIB}/libgcc_s.so.1"
179179
180+
- name: Sync Cargo.toml version
181+
env:
182+
VERSION: ${{ needs.compute-version.outputs.version }}
183+
shell: bash
184+
run: |
185+
[[ -n "$VERSION" ]] || { echo "::error::VERSION is empty — compute-version output missing"; exit 1; }
186+
CARGO="crates/codegraph-core/Cargo.toml"
187+
awk -v v="$VERSION" '!done && /^version =/{$0="version = \""v"\""; done=1}1' "$CARGO" > "${CARGO}.tmp"
188+
mv "${CARGO}.tmp" "$CARGO"
189+
180190
- name: Install napi-rs CLI
181191
run: npm install -g @napi-rs/cli@3
182192

0 commit comments

Comments
 (0)