diff --git a/.github/actions/deploy-ecs/action.yml b/.github/actions/deploy-ecs/action.yml
index a1afeaf4d..451e745d6 100644
--- a/.github/actions/deploy-ecs/action.yml
+++ b/.github/actions/deploy-ecs/action.yml
@@ -37,7 +37,7 @@ runs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- build-args: GIT_VERSION=${{ github.sha }}
+ build-args: GIT_SHA=${{ github.sha }}
- name: Kick ECS to deploy new version
shell: bash
diff --git a/crates/lib/docs_rs_utils/build.rs b/crates/lib/docs_rs_utils/build.rs
index c6bd4cd03..94e25d6a8 100644
--- a/crates/lib/docs_rs_utils/build.rs
+++ b/crates/lib/docs_rs_utils/build.rs
@@ -1,18 +1,31 @@
-use anyhow::Result;
-use std::env;
+use anyhow::{Context as _, Result, anyhow};
+use std::{env, path::PathBuf, process::Command};
fn main() -> Result<()> {
+ println!("cargo:rerun-if-changed=build.rs");
+ println!("cargo:rerun-if-env-changed=GIT_SHA");
read_git_version()?;
Ok(())
}
fn read_git_version() -> Result<()> {
if let Ok(v) = env::var("GIT_SHA") {
- // first try to read an externally provided git SAH, e.g., from CI
+ // first try to read an externally provided git SHA, e.g., from CI
println!("cargo:rustc-env=GIT_SHA={v}");
} else {
+ if let Some(path) = git_head_ref_path().context("error trying to get git head ref path")? {
+ println!("cargo:rerun-if-changed={}", path.display());
+ }
+
// then try to read the git repo.
- let maybe_hash = get_git_hash()?;
+ let maybe_hash = match git_output(["rev-parse", "--short", "HEAD"]) {
+ Ok(hash) => Some(hash),
+ Err(err) => {
+ eprintln!("error trying to get git head ref path: {:?}", err);
+ None
+ }
+ };
+
let git_hash = maybe_hash.as_deref().unwrap_or("???????");
println!("cargo:rustc-env=GIT_SHA={git_hash}");
}
@@ -25,27 +38,29 @@ fn read_git_version() -> Result<()> {
Ok(())
}
-fn get_git_hash() -> Result