diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61816ae..1d7a368 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,13 @@ jobs: targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@v2 - name: Build CLI - run: cargo build --release -p phishkit-cli --target ${{ matrix.target }} + # Bake the release version (tag without the leading `v`) into the CLI so + # `phishkit --version` reports the shipped build, not the Cargo default. + env: + PHISHKIT_VERSION: ${{ github.ref_name }} + run: | + export PHISHKIT_VERSION="${PHISHKIT_VERSION#v}" + cargo build --release -p phishkit-cli --target ${{ matrix.target }} - name: Package shell: bash run: | diff --git a/apps/cli/src/phishkit.rs b/apps/cli/src/phishkit.rs index ec08908..589e40e 100644 --- a/apps/cli/src/phishkit.rs +++ b/apps/cli/src/phishkit.rs @@ -8,6 +8,15 @@ use serde_json::json; fn main() { let mut args = env::args().skip(1).collect::>(); + if args.iter().any(|a| a == "-V" || a == "--version") + || args.first().map(|a| a == "version").unwrap_or(false) + { + println!( + "phishkit {}", + option_env!("PHISHKIT_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")) + ); + process::exit(0); + } let wants_help = args.is_empty() || args.iter().any(|a| a == "-h" || a == "--help") || args.first().map(|a| a == "help").unwrap_or(false); diff --git a/apps/cli/src/phishkit_ctl.rs b/apps/cli/src/phishkit_ctl.rs index f87e82c..ffeb0c7 100644 --- a/apps/cli/src/phishkit_ctl.rs +++ b/apps/cli/src/phishkit_ctl.rs @@ -8,6 +8,15 @@ use serde_json::json; fn main() { let mut args = env::args().skip(1).collect::>(); + if args.iter().any(|a| a == "-V" || a == "--version") + || args.first().map(|a| a == "version").unwrap_or(false) + { + println!( + "phishkit {}", + option_env!("PHISHKIT_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")) + ); + process::exit(0); + } let wants_help = args.is_empty() || args.iter().any(|a| a == "-h" || a == "--help") || args.first().map(|a| a == "help").unwrap_or(false);