Skip to content

Commit

Permalink
fix: git sha gen in linux CI
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Aug 5, 2024
1 parent 96b6ae8 commit a6818aa
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-centos7-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
docker run --rm \
-v ${{ github.workspace }}:/workspace -w /workspace \
kcllang/kcl-builder:centos7 \
/bin/bash -c "yum install -y epel-release curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel asciidoc xmlto docbook2X gcc && rpm --import https://opensource.wandisco.com/RPM-GPG-KEY-WANdisco && wget https://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm && rpm -i wandisco-git-release-7-2.noarch.rpm && yum install git -y && source ~/.bash_profile && export PATH=$PATH:/opt/build/bin/ && sed -i 's/llvm12/llvm7/g' kclvm/compiler/Cargo.toml && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email '[email protected]' && git add . && git commit -m 'chore: bump llvm version to 7.0' && make && make release"
/bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && source ~/.bash_profile && export PATH=$PATH:/opt/build/bin/ && sed -i 's/llvm12/llvm7/g' kclvm/compiler/Cargo.toml && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email '[email protected]' && git add . && git commit -m 'chore: bump llvm version to 7.0' && make && make release"
- name: Show Artifact Version
run: _build/dist/centos/kclvm/bin/kclvm_cli version
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/build-test-ubuntu-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ jobs:
docker run --rm --platform linux/arm64 \
-v ${{ github.workspace }}:/workspace -w /workspace \
kcllang/kcl-builder-arm64 \
/bin/bash -c "make && make release"
- name: Release
shell: bash
run: os=ubuntu topdir=$PWD ./scripts/release.sh
/bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email '[email protected]' && make && make release && _build/dist/ubuntu/kclvm/bin/kclvm_cli version"
- name: Upload Artifact
uses: actions/upload-artifact@v4
Expand Down
142 changes: 138 additions & 4 deletions kclvm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion kclvm/version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.10.0-alpha.2"
edition = "2021"

[build-dependencies]
vergen = { version = "8.1.3", features = ["git", "gitcl", "rustc"] }
vergen-gitcl = { version = "1.0.0", features = ["rustc"] }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
12 changes: 9 additions & 3 deletions kclvm/version/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use std::error::Error;
use vergen::EmitBuilder;
use vergen_gitcl::*;

fn main() -> Result<(), Box<dyn Error>> {
// Emit the instructions
EmitBuilder::builder().all_rustc().all_git().emit()?;
let gitcl = GitclBuilder::default().sha(false).build()?;
let rustc = RustcBuilder::all_rustc()?;

Emitter::default()
.add_instructions(&gitcl)?
.add_instructions(&rustc)?
.emit()?;

Ok(())
}
13 changes: 10 additions & 3 deletions kclvm/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
pub const VERSION: &str = include_str!("./../../../VERSION");
pub const CHECK_SUM: &str = "c020ab3eb4b9179219d6837a57f5d323";
pub const GIT_SHA: &str = env!("VERGEN_GIT_SHA");
pub const HOST_TRIPLE: &str = env!("VERGEN_RUSTC_HOST_TRIPLE");

/// Get kCL full version string with the format `{version}-{check_sum}`.
/// Get KCL full version string with the format `{version}-{check_sum}`.
#[inline]
pub fn get_version_string() -> String {
format!("{}-{}", VERSION, CHECK_SUM)
}

/// Get KCL build git sha.
#[inline]
pub fn get_git_sha() -> &'static str {
option_env!("KCL_BUILD_GIT_SHA").unwrap_or_else(|| GIT_SHA)
}

/// Get version info including version string, platform.
#[inline]
pub fn get_version_info() -> String {
format!(
"Version: {}\r\nPlatform: {}\r\nGitCommit: {}",
get_version_string(),
env!("VERGEN_RUSTC_HOST_TRIPLE"),
env!("VERGEN_GIT_SHA")
HOST_TRIPLE,
get_git_sha(),
)
}

0 comments on commit a6818aa

Please sign in to comment.