-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make git tag a single source of truth for versions, available in comp…
…ile-time
- Loading branch information
Showing
9 changed files
with
108 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build.rs export-subst |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/dist | ||
/target | ||
/vendor |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let version = match std::env::var("WLUMA_VERSION") { | ||
Ok(v) => v, | ||
Err(_) => { | ||
let version = "$Format:%(describe)$"; // Replaced by git-archive. | ||
let version = if version.starts_with('$') { | ||
match Command::new("git").args(["describe", "--tags"]).output() { | ||
Ok(o) if o.status.success() => { | ||
String::from_utf8_lossy(&o.stdout).trim().to_string() | ||
} | ||
Ok(o) => panic!("git-describe exited non-zero: {}", o.status), | ||
Err(err) => panic!("failed to execute git-describe: {err}"), | ||
} | ||
} else { | ||
version.to_string() | ||
}; | ||
|
||
let version = version.strip_prefix('v').unwrap_or(&version); | ||
println!("cargo:rustc-env=WLUMA_VERSION={version}"); | ||
version.to_string() | ||
} | ||
}; | ||
|
||
let parts = version | ||
.split(|c: char| !c.is_ascii_digit()) | ||
.collect::<Vec<_>>(); | ||
|
||
if parts.len() < 3 { | ||
panic!("Unable to parse 'major.minor.patch' from version: {version}"); | ||
} | ||
|
||
println!("cargo:rustc-env=WLUMA_VERSION_MAJOR={}", parts[0]); | ||
println!("cargo:rustc-env=WLUMA_VERSION_MINOR={}", parts[1]); | ||
println!("cargo:rustc-env=WLUMA_VERSION_PATCH={}", parts[2]); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
default: release | ||
|
||
app := "wluma" | ||
version := `echo ${WLUMA_VERSION:-$(git describe --tags)}` | ||
vendor-config := """ | ||
[source.crates-io] | ||
replace-with = "vendored-sources" | ||
[source.vendored-sources] | ||
directory = "vendor" | ||
""" | ||
|
||
release: clean vendor | ||
mkdir -p dist | ||
|
||
git -c tar.tar.gz.command="gzip -cn" archive -o "dist/{{app}}-{{version}}.tar.gz" --format tar.gz --prefix "{{app}}-{{version}}/" "{{version}}" | ||
|
||
git -c tar.tar.gz.command="gzip -cn" archive -o "dist/{{app}}-{{version}}-vendored.tar.gz" --format tar.gz \ | ||
`find vendor -type f -printf '--prefix={{app}}-{{version}}/%h/ --add-file=%p '` \ | ||
--add-virtual-file '{{app}}-{{version}}/.cargo/config.toml:{{vendor-config}}' \ | ||
--prefix "{{app}}-{{version}}/" "{{version}}" | ||
|
||
for file in dist/*; do \ | ||
gpg --detach-sign --armor "$file"; \ | ||
done | ||
|
||
rm -f "dist/{{app}}-{{version}}.tar.gz" | ||
|
||
run *args: | ||
cargo run {{args}} | ||
|
||
build *args: | ||
cargo build --locked {{args}} | ||
|
||
lint: | ||
cargo fmt -- --check | ||
cargo clippy -- -Dwarnings | ||
|
||
test: | ||
cargo test --locked | ||
|
||
vendor: | ||
cargo vendor vendor | ||
|
||
clean: | ||
rm -rf dist | ||
rm -rf vendor |
This file contains 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
This file contains 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