Skip to content

Commit 9c94481

Browse files
cleanup "v" in version in case no version is present
1 parent 2eff5f6 commit 9c94481

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

flake.nix

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@
1313

1414
# Version detection:
1515
# - When building from a git tag (e.g., nix build github:onflow/flow-cli/v2.14.2),
16-
# the version is automatically extracted from the tag: "2.14.2"
17-
# - For local development builds, version is "dev"
18-
# This eliminates the need for a separate VERSION file and keeps version
19-
# management in sync with git tags used for releases.
16+
# the version is extracted from the tag.
17+
# - For local development builds, version is "dev" (for nix metadata) and semver
18+
# is empty so build.go sets it to "undefined", matching Makefile behavior and
19+
# enabling isDevelopment() checks (skips version warnings and crash reporting).
20+
isRelease = (self ? ref) && (builtins.match "v[0-9]+\..+" self.ref != null);
2021
version =
21-
if (self ? ref) && (builtins.match "v[0-9]+\..+" self.ref != null)
22-
then builtins.substring 1 (-1) self.ref # Remove 'v' prefix from version tags
22+
if isRelease
23+
then builtins.substring 1 (-1) self.ref # Remove 'v' prefix for nix version
2324
else "dev";
25+
# semver is what gets injected into the Go binary via ldflags.
26+
# Empty string → build.go init() sets it to "undefined" → isDevelopment() == true
27+
semver =
28+
if isRelease
29+
then self.ref # Full tag with 'v' prefix (e.g., "v2.14.2")
30+
else "";
2431

2532
shortRev = self.shortRev or "dev";
2633
in
@@ -43,7 +50,7 @@
4350

4451
ldflags = [
4552
"-s" "-w"
46-
"-X github.com/onflow/flow-cli/build.semver=v${version}"
53+
"-X github.com/onflow/flow-cli/build.semver=${semver}"
4754
"-X github.com/onflow/flow-cli/build.commit=${shortRev}"
4855
"-X github.com/onflow/flow-cli/internal/accounts.accountToken=lilico:sF60s3wughJBmNh2"
4956
"-X github.com/onflow/flow-cli/internal/command.MixpanelToken=3fae49de272be1ceb8cf34119f747073"

0 commit comments

Comments
 (0)