Skip to content

Commit

Permalink
Merge branch 'add-support-for-overriding-the-versionname-used-to-gene…
Browse files Browse the repository at this point in the history
…rate-droid-1692'
  • Loading branch information
albin-mullvad committed Dec 18, 2024
2 parents 2c47294 + 35be6c3 commit b8acc74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions mullvad-version/src/main.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
7 changes: 4 additions & 3 deletions prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down

0 comments on commit b8acc74

Please sign in to comment.