Skip to content
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

Added Git version at build-time #685

Merged
merged 2 commits into from
Apr 10, 2025
Merged

Conversation

Thesola10
Copy link

@Thesola10 Thesola10 commented Mar 5, 2025

This commit also updates flake.lock and Cargo.lock due to built requiring rustc >= 1.81

Both the command-line -V option and the generated script header will use the Git-formatted version if Git was available at build-time, and the commit differs from the latest tag.

This fixes #635

This commit also updates flake.lock and Cargo.lock due to built requiring
rustc >= 1.81
Due to the way Nix flakes work, building Amber through Nix removes Git metadata.
To work around this, I systematically append -nix-COMMIT (or -nix-dirty) to the
version string for Amber built with Nix.
@Thesola10 Thesola10 changed the base branch from main to staging March 5, 2025 14:25
@Mte90 Mte90 requested review from hdwalters and Ph0enixKM March 5, 2025 15:32
@karpfediem
Copy link
Contributor

generally looking good to me, and i like this approach

The build via nix flake works fine :)

nix run git+https://github.com/Thesola10/amber?ref=git-version -- -V
amber 0.4.0-alpha-nix-a71cc4e

However with cargo i noticed a commit hash that does not seem to exist (?)

cargo run -- -V
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/amber -V`
amber 0.4.0-alpha-2-ga71cc4e

I also tried to clean the repo (git clean -fd) and cargo clean, but still shows this commit hash for some reason.
Any ideas @Thesola10?

@Thesola10
Copy link
Author

The hash provided by built starts with g, if you read the rest the hash is identical to your flake build

@karpfediem
Copy link
Contributor

Yes but I don't understand why/where it prepends a g

Seems especially confusing with the format otherwise matching git describe

@Thesola10
Copy link
Author

it's just the way built does things, you should file a bug at lukaslueg/built

@b1ek
Copy link
Member

b1ek commented Mar 9, 2025

what about releases though? i dont think the commit tag is necessary anywhere else other than the developement/nightly versions

@Ph0enixKM
Copy link
Member

Exactly. Does it append the tag on release versions too?

@Thesola10
Copy link
Author

No it doesnt append a commit if the HEAD is tagged

@Mte90 Mte90 merged commit 02c4094 into amber-lang:staging Apr 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants