Merge pull request #504 from KoviRobi/master

Draft: Long version & nix flakes
This commit is contained in:
Clément DOUIN
2024-11-22 09:50:55 +01:00
committed by GitHub
5 changed files with 55 additions and 19 deletions
+15 -6
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
+15 -6
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
+20 -5
View File
@@ -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}");
+2 -1
View File
@@ -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)"
+3 -1
View File
@@ -84,7 +84,9 @@ impl Cli {
env!("TARGET_ENV"),
" ",
env!("TARGET_ARCH"),
", git rev ",
", git ",
env!("GIT_DESCRIBE"),
" rev ",
env!("GIT_REV"),
);
}