diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94e4d9b..422394d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,10 @@ jobs: git fetch --quiet origin main git merge-base --is-ancestor "$(git rev-parse "${TAG}^{commit}")" origin/main \ || { echo "::error::$TAG is not on main"; exit 1; } - want="v$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" + # The tag names the version as the binary shows it: Cargo's 27.1.0 is + # v27.1 and 27.1.0-rc.1 is v27.1-rc.1 (src/version.rs). + want="v$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version' \ + | sed -E 's/^([0-9]+[.][0-9]+)[.]0(-|$)/\1\2/')" [ "$TAG" = "$want" ] || { echo "::error::$TAG does not match Cargo.toml ($want)"; exit 1; } build: @@ -187,7 +190,7 @@ jobs: id="$(curl -fsS "${auth[@]}" "$API/releases/tags/$TAG" 2>/dev/null | jq -r '.id // empty' || true)" if [ -z "$id" ]; then id="$(curl -fsS "${auth[@]}" -H 'Content-Type: application/json' \ - -d "$(jq -n --arg t "$TAG" --arg b "$notes" '{tag_name:$t, name:$t, draft:true, body:$b}')" \ + -d "$(jq -n --arg t "$TAG" --arg b "$notes" '{tag_name:$t, name:$t, draft:true, body:$b, prerelease:($t | contains("-rc."))}')" \ "$API/releases" | jq -r '.id // empty')" [ -n "$id" ] || { echo "::error::could not create the release"; exit 1; } created=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 63a4096..ba5080e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,17 @@ # Change Log -All notable changes to this project are recorded here. Versions are dates: -release `v2026.9.30` is version `2026.9.30`. +All notable changes to this project are recorded here. Versions follow the +inbuxa suite: a series (`27.1`), its patches (`27.1.3`) and release +candidates before a series ships (`27.1-rc.1`). The tag is the version with a +`v`. Releases before 27.1 were dates (`v2026.9.30`). + +## [27.1-rc.1] + +The first release candidate of the 27.1 series, with the rest of the suite. + +### Changed +- `--version` and the User-Agent show the version as tags name it + (`27.1-rc.1`). ## [2026.10.26] -- 2026-10-26 diff --git a/Cargo.lock b/Cargo.lock index 2240f2a..cc8ac1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1325,7 +1325,7 @@ dependencies = [ [[package]] name = "inbuxa-migrate" -version = "2026.10.26" +version = "27.1.0-rc.1" dependencies = [ "blake3", "calcard", diff --git a/Cargo.toml b/Cargo.toml index 6d820fd..cbcad30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "inbuxa-migrate" description = "Account migration and backup for inbuxa" -version = "2026.10.26" +version = "27.1.0-rc.1" authors = ["Coffey Labs LLC "] license = "Apache-2.0 OR MIT" repository = "https://git.coffeylabs.org/inbuxa/inbuxa-migrate" diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 42be117..7b7da37 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -24,7 +24,9 @@ case "$(uname -m)" in esac # The tag names the version the binary reports, so the two cannot disagree. -want="v$(cd "$ROOT" && cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" +# Cargo's 27.1.0 is tagged v27.1, and 27.1.0-rc.1 v27.1-rc.1 (src/version.rs). +want="v$(cd "$ROOT" && cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version' \ + | sed -E 's/^([0-9]+[.][0-9]+)[.]0(-|$)/\1\2/')" [ "$VERSION" = "$want" ] || { echo "tag $VERSION does not match Cargo.toml ($want)" >&2; exit 1; } name="inbuxa-migrate-linux-$arch" diff --git a/src/cli.rs b/src/cli.rs index c24aa3a..d21278b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -32,7 +32,7 @@ use crate::types::{ObjectType, parse_object_list}; #[derive(Parser)] #[command( name = "inbuxa-migrate", - version, + version = crate::version::shown(), about = "inbuxa-migrate: account migration and backup for inbuxa" )] pub struct Cli { diff --git a/src/dav/client.rs b/src/dav/client.rs index 91e5a8e..fc050bf 100644 --- a/src/dav/client.rs +++ b/src/dav/client.rs @@ -101,7 +101,7 @@ impl DavClient { log_level: AtomicU8::new(LEVEL_DEFAULT), retries_total: AtomicU64::new(0), retry_after_sleeps: AtomicU64::new(0), - user_agent: format!("inbuxa-migrate/{}", env!("CARGO_PKG_VERSION")), + user_agent: format!("inbuxa-migrate/{}", crate::version::shown()), }), } } diff --git a/src/exchange_ews/client.rs b/src/exchange_ews/client.rs index 8015051..90e2289 100644 --- a/src/exchange_ews/client.rs +++ b/src/exchange_ews/client.rs @@ -95,7 +95,7 @@ impl EwsClient { retries_total: AtomicU64::new(0), retry_after_sleeps: AtomicU64::new(0), soap_calls: AtomicU64::new(0), - user_agent: format!("inbuxa-migrate/{}", env!("CARGO_PKG_VERSION")), + user_agent: format!("inbuxa-migrate/{}", crate::version::shown()), }), } } diff --git a/src/exchange_graph/client.rs b/src/exchange_graph/client.rs index 0e1e017..d540a2e 100644 --- a/src/exchange_graph/client.rs +++ b/src/exchange_graph/client.rs @@ -126,7 +126,7 @@ impl GraphClient { retries_total: AtomicU64::new(0), retry_after_sleeps: AtomicU64::new(0), requests_total: AtomicU64::new(0), - user_agent: format!("inbuxa-migrate/{}", env!("CARGO_PKG_VERSION")), + user_agent: format!("inbuxa-migrate/{}", crate::version::shown()), }), } } diff --git a/src/lib.rs b/src/lib.rs index e513ad1..4d0d2c5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,3 +21,4 @@ pub mod net; pub mod secret; pub mod sync; pub mod types; +pub mod version; diff --git a/src/version.rs b/src/version.rs new file mode 100644 index 0000000..1bdb07b --- /dev/null +++ b/src/version.rs @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2026 Coffey Labs LLC + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + */ + +//! The version as tags name it: Cargo's `27.1.0` is `27.1`, `27.1.3` stays +//! `27.1.3`, `27.1.0-rc.1` is `27.1-rc.1`, the same rule as the rest of the +//! inbuxa suite. `--version` and the User-Agent show it; the release workflow +//! checks the tag against it. + +use std::sync::OnceLock; + +/// This build's version, as tags name it. +pub fn shown() -> &'static str { + static SHOWN: OnceLock = OnceLock::new(); + SHOWN.get_or_init(|| display(env!("CARGO_PKG_VERSION"))) +} + +fn display(cargo: &str) -> String { + let (core, pre) = match cargo.split_once('-') { + Some((core, pre)) => (core, Some(pre)), + None => (cargo, None), + }; + match core.strip_suffix(".0") { + Some(series) if series.matches('.').count() == 1 => match pre { + Some(pre) => format!("{series}-{pre}"), + None => series.to_string(), + }, + _ => cargo.to_string(), + } +} + +#[cfg(test)] +mod tests { + use super::{display, shown}; + + #[test] + fn shown_as_tags_name_it() { + assert_eq!(display("27.1.0"), "27.1"); + assert_eq!(display("27.1.3"), "27.1.3"); + assert_eq!(display("27.1.0-rc.1"), "27.1-rc.1"); + assert_eq!(display("28.7.10"), "28.7.10"); + assert_eq!(display("2026.10.26"), "2026.10.26"); + assert!(!shown().is_empty()); + } +}