From 98d7c11b49050f4647de8c401b065044efdc59d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalle=20Lindstr=C3=B6m?= Date: Wed, 18 Dec 2024 17:28:57 +0100 Subject: [PATCH 1/2] Add support for overriding Android version --- mullvad-version/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mullvad-version/src/main.rs b/mullvad-version/src/main.rs index 7f9001ec6159..1317260a2fd0 100644 --- a/mullvad-version/src/main.rs +++ b/mullvad-version/src/main.rs @@ -1,16 +1,24 @@ use mullvad_version::{PreStableType, Version}; +use std::env::VarError; use std::{env, process::exit}; const ANDROID_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/android-version-name.txt")); fn main() { + let android_version_env = env::var("ANDROID_VERSION"); + if matches!(android_version_env, Err(VarError::NotUnicode(_))) { + eprintln!("ANDROID_VERSION is not valid unicode."); + exit(1); + } + let android_version = android_version_env.unwrap_or(ANDROID_VERSION.to_string()); + let command = env::args().nth(1); match command.as_deref() { None => println!("{}", mullvad_version::VERSION), Some("semver") => println!("{}", to_semver(mullvad_version::VERSION)), Some("version.h") => println!("{}", to_windows_h_format(mullvad_version::VERSION)), - Some("versionName") => println!("{ANDROID_VERSION}"), - Some("versionCode") => println!("{}", to_android_version_code(ANDROID_VERSION)), + Some("versionName") => println!("{android_version}"), + Some("versionCode") => println!("{}", to_android_version_code(&android_version)), Some(command) => { eprintln!("Unknown command: {command}"); exit(1); From 35be6c375fd217f33f646fac925683614aa167a6 Mon Sep 17 00:00:00 2001 From: Albin Date: Wed, 18 Dec 2024 17:37:36 +0100 Subject: [PATCH 2/2] Use override in prepare script --- prepare-release.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/prepare-release.sh b/prepare-release.sh index 087c3c08fb73..b1e7da8f968b 100755 --- a/prepare-release.sh +++ b/prepare-release.sh @@ -74,10 +74,11 @@ fi if [[ "$ANDROID" == "true" ]]; then echo "$PRODUCT_VERSION" > dist-assets/android-version-name.txt + ANDROID_VERSION="$PRODUCT_VERSION" cargo run -q --bin mullvad-version versionCode > \ + dist-assets/android-version-code.txt git commit -S -m "Update android app version to $PRODUCT_VERSION" \ - dist-assets/android-version-name.txt - cargo run -q --bin mullvad-version versionCode > dist-assets/android-version-code.txt - git commit -S --amend --no-edit dist-assets/android-version-code.txt + dist-assets/android-version-name.txt \ + dist-assets/android-version-code.txt fi NEW_TAGS=""