diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 504aed7..f6b1c18 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - uses: actions/cache@v3 @@ -26,9 +26,15 @@ jobs: run: | fixtures/start_fileserver.sh & + - name: Remove files for a build with correct version info + run: | + find target/ -name 'shadow*' -exec rm -r {} + || true + find target/ -name 'tsumugu' -delete || true - name: Test & Compile run: | mkdir -p ~/.cargo/{git,registry} + # Fix git permission issue with Docker and shadow-rs + sudo chown -R root . docker run --rm -t \ --mount type=bind,source=${{ github.workspace }},target=/volume \ --mount type=bind,source=$HOME/.cargo/registry,target=/root/.cargo/registry \ @@ -44,7 +50,9 @@ jobs: clux/muslrust:stable \ cargo build --release sudo chown -R runner ~/.cargo/ - sudo chown -R runner target/ + sudo chown -R runner . + # show version info + RUST_LOG=debug target/x86_64-unknown-linux-musl/release/tsumugu --version - name: Deploy - Create and Upload Release if: startsWith(github.ref, 'refs/tags/') diff --git a/Cargo.lock b/Cargo.lock index c2a7a17..40bf558 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -659,9 +659,9 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git2" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ "bitflags 2.6.0", "libc", @@ -922,9 +922,9 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libgit2-sys" -version = "0.16.2+1.7.2" +version = "0.17.0+1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", @@ -1661,9 +1661,9 @@ dependencies = [ [[package]] name = "shadow-rs" -version = "0.26.1" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5c5c8276991763b44ede03efaf966eaa0412fafbf299e6380704678ca3b997" +checksum = "25d4535372eab969a98536e39dd272bca49fc338b09b25babea715968d15eeae" dependencies = [ "const_format", "git2", diff --git a/Cargo.toml b/Cargo.toml index 3d27f6e..d092577 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,10 +26,10 @@ humansize = "2.1.3" console = { version = "0.15", default-features = false, features = ["ansi-parsing"] } apt-parser = "1.0.0" flate2 = "1.0.28" -shadow-rs = "0.26.1" +shadow-rs = "0.32.0" [build-dependencies] -shadow-rs = "0.26.1" +shadow-rs = "0.32.0" [dev-dependencies] test-log = { version = "0.2.14", default-features = false, features = ["trace"] } diff --git a/src/main.rs b/src/main.rs index af5ed9e..9eb0026 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,10 +22,22 @@ mod extensions; use crate::regex_process::ExpandedRegex; +fn get_version() -> &'static str { + let tag = build::TAG; + let clean = build::GIT_CLEAN; + if !clean { + return Box::leak(format!("{} (dirty)", build::SHORT_COMMIT).into_boxed_str()); + } else if tag.len() == 0 { + return build::SHORT_COMMIT; + } else { + return tag; + } +} + #[derive(Parser, Debug)] #[command(about)] #[command(propagate_version = true)] -#[command(version = build::SHORT_COMMIT)] +#[command(version = get_version())] struct Cli { #[command(subcommand)] command: Commands,