summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--src/core/build.rs12
2 files changed, 14 insertions, 4 deletions
diff --git a/README.md b/README.md
index 22918a6..f860bf9 100644
--- a/README.md
+++ b/README.md
@@ -256,12 +256,16 @@ An addition to the report printed to the CLI, an HTML report can be found in the
### Release
-##### Building
+#### Debian Building
cargo make deb
A deb file will be written to `target/debian/interactive-rebase-tool_*.deb`.
+#### Reproducible Builds
+
+Providing a [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/specs/source-date-epoch/#idm55) environment variable with a valid UNIX timestamp, defined in seconds, will ensure a reproducible build.
+
## Related Projects
* [rebase-editor](https://github.com/sjurba/rebase-editor) is a very similar project written in Node.js.
diff --git a/src/core/build.rs b/src/core/build.rs
index b8b88bc..f528155 100644
--- a/src/core/build.rs
+++ b/src/core/build.rs
@@ -1,6 +1,6 @@
-use std::process;
+use std::{env, process};
-use chrono::Utc;
+use chrono::{TimeZone, Utc};
use rustc_version::{version_meta, Channel};
fn main() {
@@ -16,7 +16,13 @@ fn main() {
if let Some(rev) = git_revision_hash() {
println!("cargo:rustc-env=GIRT_BUILD_GIT_HASH={rev}");
}
- println!("cargo:rustc-env=GIRT_BUILD_DATE={}", Utc::now().format("%Y-%m-%d"));
+
+ // Use provided SOURCE_DATE_EPOCH to make builds reproducible
+ let build_date = match env::var("SOURCE_DATE_EPOCH") {
+ Ok(val) => Utc.timestamp_opt(val.parse::<i64>().unwrap(), 0).unwrap(),
+ Err(_) => Utc::now(),
+ };
+ println!("cargo:rustc-env=GIRT_BUILD_DATE={}", build_date.format("%Y-%m-%d"));
}
fn git_revision_hash() -> Option<String> {