Skip to content

Commit

Permalink
Port version and git fix to CI configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Aug 21, 2024
1 parent d0f566f commit 80ac7f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ jobs:
~/.cargo/git
target
key: musl-cargo-${{ hashFiles('**/Cargo.toml') }}
- 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 \
Expand All @@ -40,7 +46,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/yukina --version
- name: Deploy - Create and Upload Release
if: startsWith(github.ref, 'refs/tags/')
Expand Down
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ fn parse_bytes(s: &str) -> Result<u64, clap::Error> {
}

fn get_version() -> &'static str {
if build::SHORT_COMMIT.is_empty() {
build::LAST_TAG
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.is_empty() {
return build::SHORT_COMMIT;
} else {
build::SHORT_COMMIT
return tag;
}
}

Expand Down

0 comments on commit 80ac7f6

Please sign in to comment.