Compare commits

...

5 commits

Author SHA1 Message Date
Kovacsics Robert
a0485ff8d1 Override git describe in CI 2024-11-21 16:31:11 +00:00
Kovacsics Robert
c36e72b5f6 Allow passing in GIT_DESCRIBE/GIT_REV to avoid git repo
This should allow building inside a flake
2024-11-21 16:31:11 +00:00
Kovacsics Robert
2e3a3397a5 Update cargo lock file for openssl removal 2024-11-21 16:20:27 +00:00
Clément DOUIN
d7c4abf2e3
remove git2 default features
The crate comes with openssl-related features by default, which breaks
the CI on MacOS.
2024-11-20 15:49:22 +01:00
Clément DOUIN
36f3690cba
fix long version on nix and ci 2024-11-20 15:00:17 +01:00
8 changed files with 81 additions and 75 deletions

View file

@ -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

View file

@ -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

30
Cargo.lock generated
View file

@ -1626,8 +1626,6 @@ dependencies = [
"libc",
"libgit2-sys",
"log",
"openssl-probe",
"openssl-sys",
"url",
]
@ -2353,9 +2351,7 @@ checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224"
dependencies = [
"cc",
"libc",
"libssh2-sys",
"libz-sys",
"openssl-sys",
"pkg-config",
]
@ -2387,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"
@ -2878,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"

View file

@ -46,7 +46,7 @@ pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pimalaya-tui/pgp-gpg", "pgp"
pgp-native = ["email-lib/pgp-native", "mml-lib/pgp-native", "pimalaya-tui/pgp-native", "pgp"]
[build-dependencies]
git2 = "0.19"
git2 = { version = "0.19", default-features = false }
[dependencies]
ariadne = "0.2"

View file

@ -3,36 +3,33 @@ use std::env;
use git2::Repository;
fn main() {
let repo = Repository::open(".").expect("should open git repository");
let head = repo.head().expect("should get HEAD");
let branch = head.shorthand().expect("should get branch name");
let commit = head.peel_to_commit().expect("should get HEAD commit");
let rev = commit.id().to_string();
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 version = env!("CARGO_PKG_VERSION");
let os = env::var("CARGO_CFG_TARGET_OS").expect("should get CARGO_CFG_TARGET_OS");
println!("cargo::rustc-env=TARGET_OS={os}");
let env = env::var("CARGO_CFG_TARGET_ENV").expect("should get CARGO_CFG_TARGET_ENV");
println!("cargo::rustc-env=TARGET_ENV={env}");
let arch = env::var("CARGO_CFG_TARGET_ARCH").expect("should get CARGO_CFG_TARGET_ARCH");
let long_version = [
version,
&os,
&env,
&arch,
"git branch",
&branch,
"rev",
&rev,
]
.into_iter()
.filter(|s| !s.trim().is_empty())
.fold(String::new(), |mut version, section| {
if !version.is_empty() {
version.push(' ')
}
version.push_str(section);
version
});
println!("cargo::rustc-env=HIMALAYA_LONG_VERSION={long_version}");
println!("cargo::rustc-env=TARGET_ARCH={arch}");
}

View file

@ -79,11 +79,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1730137625,
"narHash": "sha256-9z8oOgFZiaguj+bbi3k4QhAD6JabWrnv7fscC/mt0KE=",
"lastModified": 1731797254,
"narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "64b80bfb316b57cdb8919a9110ef63393d74382a",
"rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
"type": "github"
},
"original": {

View file

@ -134,6 +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 "unknown-rev";
GIT_DESCRIBE = "flake-" + self.shortRev or self.dirtyShortRev or "unknown";
postInstall = ''
export WINEPREFIX="$(mktemp -d)"

View file

@ -24,7 +24,9 @@ use crate::{
};
#[derive(Parser, Debug)]
#[command(name = "himalaya", author, version, about)]
#[command(name = env!("CARGO_PKG_NAME"))]
#[command(author, version, about)]
#[command(long_version = Cli::LONG_VERSION)]
#[command(propagate_version = true, infer_subcommands = true)]
pub struct Cli {
#[command(subcommand)]
@ -72,6 +74,23 @@ pub struct Cli {
pub trace: bool,
}
impl Cli {
pub const LONG_VERSION: &'static str = concat!(
"v",
env!("CARGO_PKG_VERSION"),
" on ",
env!("TARGET_OS"),
" ",
env!("TARGET_ENV"),
" ",
env!("TARGET_ARCH"),
", git ",
env!("GIT_DESCRIBE"),
" rev ",
env!("GIT_REV"),
);
}
#[derive(Subcommand, Debug)]
pub enum HimalayaCommand {
#[command(subcommand)]