From 2e3a3397a56e25903f16c25bbc8733f09a2bf1b1 Mon Sep 17 00:00:00 2001 From: Kovacsics Robert Date: Thu, 21 Nov 2024 16:20:03 +0000 Subject: [PATCH 1/3] Update cargo lock file for openssl removal --- Cargo.lock | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa92ad26..3096ffaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2351,9 +2351,7 @@ checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", - "libssh2-sys", "libz-sys", - "openssl-sys", "pkg-config", ] @@ -2385,20 +2383,6 @@ dependencies = [ "redox_syscall 0.5.7", ] -[[package]] -name = "libssh2-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - [[package]] name = "libz-sys" version = "1.1.20" @@ -2876,18 +2860,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-sys" -version = "0.9.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" From c36e72b5f6f1cb6fb60c0e2e384e885fb7e4d298 Mon Sep 17 00:00:00 2001 From: Kovacsics Robert Date: Wed, 20 Nov 2024 11:55:53 +0000 Subject: [PATCH 2/3] Allow passing in GIT_DESCRIBE/GIT_REV to avoid git repo This should allow building inside a flake --- build.rs | 25 ++++++++++++++++++++----- flake.nix | 3 ++- src/cli.rs | 4 +++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index afd452cc..288a0b17 100644 --- a/build.rs +++ b/build.rs @@ -3,11 +3,26 @@ use std::env; use git2::Repository; fn main() { - if let Ok(repo) = Repository::open(".") { - let head = repo.head().expect("should get git HEAD"); - let commit = head.peel_to_commit().expect("should get git HEAD commit"); - println!("cargo::rustc-env=GIT_REV={}", commit.id()); - } + let branch = if let Ok(describe) = env::var("GIT_DESCRIBE") { + describe + } else { + let repo = Repository::open(".").expect("should open git repository"); + let head = repo.head().expect("should get HEAD"); + head.shorthand() + .expect("should get branch name") + .to_string() + }; + println!("cargo::rustc-env=GIT_DESCRIBE={branch}"); + + let rev = if let Ok(rev) = env::var("GIT_REV") { + rev + } else { + let repo = Repository::open(".").expect("should open git repository"); + let head = repo.head().expect("should get HEAD"); + let commit = head.peel_to_commit().expect("should get HEAD commit"); + commit.id().to_string() + }; + println!("cargo::rustc-env=GIT_REV={rev}"); let os = env::var("CARGO_CFG_TARGET_OS").expect("should get CARGO_CFG_TARGET_OS"); println!("cargo::rustc-env=TARGET_OS={os}"); diff --git a/flake.nix b/flake.nix index 4abdb9b0..d8521844 100644 --- a/flake.nix +++ b/flake.nix @@ -134,7 +134,8 @@ nativeBuildInputs = with pkgs; [ pkg-config ]; CARGO_BUILD_TARGET = targetConfig.rustTarget; CARGO_BUILD_RUSTFLAGS = [ "-Ctarget-feature=+crt-static" ]; - GIT_REV = self.rev or self.dirtyRev or "dirty"; + GIT_REV = self.rev or self.dirtyRev or "unknown-rev"; + GIT_DESCRIBE = "flake-" + self.shortRev or self.dirtyShortRev or "unknown"; postInstall = '' export WINEPREFIX="$(mktemp -d)" diff --git a/src/cli.rs b/src/cli.rs index cc3f4d67..6d365a98 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -84,7 +84,9 @@ impl Cli { env!("TARGET_ENV"), " ", env!("TARGET_ARCH"), - ", git rev ", + ", git ", + env!("GIT_DESCRIBE"), + " rev ", env!("GIT_REV"), ); } From a0485ff8d18482499bde88e177ff8d989b0d2e5e Mon Sep 17 00:00:00 2001 From: Kovacsics Robert Date: Wed, 20 Nov 2024 13:54:32 +0000 Subject: [PATCH 3/3] Override git describe in CI --- .github/workflows/pre-release.yml | 21 +++++++++++++++------ .github/workflows/release.yml | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 219c35d4..58f3e68b 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -10,15 +10,20 @@ jobs: fail-fast: false matrix: include: - - target: x86_64-linux + - host: x86_64-linux + target: x86_64-linux os: ubuntu-latest - - target: aarch64-linux + - host: x86_64-linux + target: aarch64-linux os: ubuntu-latest - - target: x86_64-windows + - host: x86_64-linux + target: x86_64-windows os: ubuntu-latest - - target: x86_64-darwin + - host: x86_64-darwin + target: x86_64-darwin os: macos-13 - - target: aarch64-darwin + - host: aarch64-darwin + target: aarch64-darwin os: macos-14 steps: - name: Checkout code @@ -37,7 +42,11 @@ jobs: extraPullNames: nix-community - name: Build release run: | - nix build -L .#${{ matrix.target }} + nix build -L --expr " + (builtins.getFlake \"git+file://${PWD}?shallow=1&rev=$(git rev-parse HEAD)\") + .outputs.packages.${{ matrix.host }}.${{ matrix.target }}.overrideAttrs { + GIT_DESCRIBE = \"$(git describe --always)\"; + }" nix run -L .#${{ matrix.target }} -- --version - name: Upload release artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 352c0248..27d8f343 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,15 +29,20 @@ jobs: fail-fast: false matrix: include: - - target: x86_64-linux + - host: x86_64-linux + target: x86_64-linux os: ubuntu-latest - - target: aarch64-linux + - host: x86_64-linux + target: aarch64-linux os: ubuntu-latest - - target: x86_64-windows + - host: x86_64-linux + target: x86_64-windows os: ubuntu-latest - - target: x86_64-darwin + - host: x86_64-darwin + target: x86_64-darwin os: macos-13 - - target: aarch64-darwin + - host: aarch64-darwin + target: aarch64-darwin os: macos-14 steps: - name: Checkout code @@ -55,7 +60,11 @@ jobs: extraPullNames: nix-community - name: Build release archive run: | - nix build -L .#${{ matrix.target }} + nix build -L --expr " + (builtins.getFlake \"git+file://${PWD}?shallow=1&rev=$(git rev-parse HEAD)\") + .outputs.packages.${{ matrix.host }}.${{ matrix.target }}.overrideAttrs { + GIT_DESCRIBE = \"$(git describe)\"; + }" cp result/himalaya* . - name: Upload tgz release archive uses: actions/upload-release-asset@v1