version: report CalVer instead of the crate version
Releases are tagged YYYY-MM-DD+SHORT_SHA, but --version read the
unbumped 0.1.0 from Cargo.toml, so every shipped binary claimed the
same version.
Assisted-by: Claude Opus 5 via Claude Code
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 482082b..2e78851 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -38,8 +38,10 @@ jobs:
- name: Build
run: |
- cargo build --release -p frork-cli
+ FRORK_VERSION="${STEPS_VERSION_OUTPUTS_VERSION}" cargo build --release -p frork-cli
tar -czf frork-aarch64-apple-darwin.tar.gz -C target/release frork
+ env:
+ STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }}
- name: Publish
run: |
diff --git a/frork-cli/build.rs b/frork-cli/build.rs
new file mode 100644
index 0000000..ef8fdd8
--- /dev/null
+++ b/frork-cli/build.rs
@@ -0,0 +1,23 @@
+use std::process::Command;
+
+fn main() {
+ let version = std::env::var("FRORK_VERSION").unwrap_or_else(|_| {
+ let date = cmd("date", &["-u", "+%Y-%m-%d"]);
+ let change = cmd(
+ "jj",
+ &["log", "-r", "@", "--no-graph", "-T", "change_id.short()"],
+ );
+ format!("{date}+{change}-dev")
+ });
+ println!("cargo:rustc-env=FRORK_VERSION={version}");
+}
+
+fn cmd(program: &str, args: &[&str]) -> String {
+ Command::new(program)
+ .args(args)
+ .output()
+ .ok()
+ .and_then(|o| String::from_utf8(o.stdout).ok())
+ .map(|s| s.trim().to_string())
+ .unwrap_or_else(|| "unknown".into())
+}
diff --git a/frork-cli/src/main.rs b/frork-cli/src/main.rs
index 3847e01..7dc302f 100644
--- a/frork-cli/src/main.rs
+++ b/frork-cli/src/main.rs
@@ -43,8 +43,11 @@ use mlua::prelude::*;
use tracing::info;
use utils::Utils;
+/// CalVer, set by build.rs — the crate version is not what ships.
+const VERSION: &str = env!("FRORK_VERSION");
+
#[derive(Parser)]
-#[command(name = "frork", version)]
+#[command(name = "frork", version = VERSION)]
#[command(about = "A Fennel-based configuration management tool")]
struct Cli {
/// Generate shell completions and exit.