Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for overriding Android version #7372

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading