Skip to content

Commit

Permalink
Define versioning policy
Browse files Browse the repository at this point in the history
Specifically, reserve patch releases for releases without release notes
such as translation updates, to be able to ship meaningful release notes
to users while updating translations at any point in time.

Adapt the about dialog to show the cargo version number, but use only
its major and minor parts for the release notes version number.
  • Loading branch information
swsnr committed Jan 2, 2025
1 parent bddb113 commit 16ca5af
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ homepage = "https://github.com/swsnr/turnon"
repository = "https://github.com/swsnr/turnon"
license = "MPL-2.0"
authors = ["Sebastian Wiesner <[email protected]>"]
# Our version number. Since semver doesn't make much sense for UI applications
# which have no API we repurpose the version numer as follows:
#
# - major: Major new features or major changes to the UI, which may break the app for some users.
# - minor: User-visible features or bugfixes.
# - patch: Translation updates.
#
# Major and minor releases get release notes, but patch releases do not; this
# enables us to ship updates to translations whenever translators contributed
# new languages or made major updates, while still providing meaningful release
# notes for the last functional changes.
version = "2.1.0"
edition = "2021"
publish = false
Expand All @@ -22,6 +33,7 @@ serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
socket2 = "0.5.7"
bitflags = "2.6.0"
semver = "1.0.24"

[build-dependencies]
glob = "0.3.1"
Expand Down
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ impl TurnOnApplication {
fn show_about_dialog(&self) {
let dialog = adw::AboutDialog::from_appdata(
"/de/swsnr/turnon/de.swsnr.turnon.metainfo.xml",
Some(crate::config::VERSION),
Some(&crate::config::release_notes_version()),
);
dialog.set_version(crate::config::VERSION);
dialog.set_version(crate::config::CARGO_PKG_VERSION);

glib::spawn_future_local(glib::clone!(
#[strong(rename_to = devices)]
Expand Down
2 changes: 1 addition & 1 deletion src/app/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl DebugInfo {
.unwrap();
DebugInfo {
app_id: config::APP_ID,
version: config::VERSION,
version: config::CARGO_PKG_VERSION,
flatpak: config::running_in_flatpak(),
connectivity,
ping_results,
Expand Down
28 changes: 25 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::path::PathBuf;
use std::{borrow::Cow, path::PathBuf};

use glib::{gstr, GStr};
use gtk::gio;

/// The app ID to use.
pub static APP_ID: &GStr = gstr!("de.swsnr.turnon");

/// The app version.
pub static VERSION: &str = env!("CARGO_PKG_VERSION");
/// The Cargo package verson.
///
/// This provides the full version from `Cargo.toml`.
pub static CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");

/// The version to use for release notes.
///
/// For nightly builds (see [`is_development`]) this returns `next`, otherwise
/// it returns [`CARGO_PKG_VERSION`] but with patch set to 0, and all pre and
/// build parts emptied.
///
/// This follows our versioning policy which uses patch releases only for
/// translation updates.
pub fn release_notes_version() -> Cow<'static, str> {
if is_development() {
Cow::Borrowed("next")
} else {
let mut version = semver::Version::parse(CARGO_PKG_VERSION).unwrap();
version.patch = 0;
version.pre = semver::Prerelease::EMPTY;
version.build = semver::BuildMetadata::EMPTY;
version.to_string().into()
}
}

pub const G_LOG_DOMAIN: &str = "TurnOn";

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ fn main() -> glib::ExitCode {
glib::set_application_name("Turn On");

let app = TurnOnApplication::default();
app.set_version(config::VERSION);
app.set_version(config::CARGO_PKG_VERSION);
app.run()
}

0 comments on commit 16ca5af

Please sign in to comment.