diff --git a/Documentation/ConfigurationManagement.md b/Documentation/ConfigurationManagement.md index 548e84759..154d72e62 100644 --- a/Documentation/ConfigurationManagement.md +++ b/Documentation/ConfigurationManagement.md @@ -74,6 +74,21 @@ android: - feature_flags.yaml ``` +## App Version + +Set these top-level keys in the selected environment's `config.yaml` (including your custom config directory, if used): + +```yaml +VERSION_CODE: 2 +VERSION_NAME: '1.0.1' +``` + +- `VERSION_CODE` sets Android's `versionCode`. It must be an integer from `1` to `2100000000`; invalid values fail during Gradle configuration. Integer values and quoted integer strings are supported. +- `VERSION_NAME` sets the user-visible Android `versionName`; use a quoted string. +- If omitted, the values default to `1` and `'1.0.0'`, respectively. + +Increment `VERSION_CODE` for each Google Play upload, using a value higher than any previously uploaded version for the same application ID. Changing `VERSION_NAME` alone does not satisfy this requirement. + ## Available Third-Party Services - **Firebase:** Analytics, Crashlytics, Cloud Messaging - **Google:** Sign in and Sign up via Google diff --git a/app/build.gradle b/app/build.gradle index 688d38232..644412f37 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,13 @@ def config = configHelper.fetchConfig() def appId = config.getOrDefault("APPLICATION_ID", "org.openedx.app") +def appVersionCode = config.getOrDefault("VERSION_CODE", 1)?.toString() +def appVersionName = config.getOrDefault("VERSION_NAME", "1.0.0") + +if (!(appVersionCode ==~ /[0-9]+/) || !appVersionCode.isInteger() || + appVersionCode.toInteger() < 1 || appVersionCode.toInteger() > 2100000000) { + throw new GradleException("VERSION_CODE must be an integer between 1 and 2100000000 in the YAML config.") +} + def themeDirectory = config.getOrDefault("THEME_DIRECTORY", "openedx") def firebaseConfig = config.get('FIREBASE') def firebaseEnabled = firebaseConfig?.getOrDefault('ENABLED', false) @@ -35,8 +43,8 @@ android { applicationId appId minSdk min_sdk_version targetSdk target_sdk_version - versionCode 1 - versionName "1.0.0" + versionCode appVersionCode.toInteger() + versionName appVersionName resourceConfigurations += ["en", "uk"] diff --git a/default_config/dev/config.yaml b/default_config/dev/config.yaml index f2868eb78..653fb81a0 100644 --- a/default_config/dev/config.yaml +++ b/default_config/dev/config.yaml @@ -1,5 +1,7 @@ API_HOST_URL: 'http://localhost:8000' APPLICATION_ID: 'org.openedx.app' +VERSION_CODE: 1 +VERSION_NAME: '1.0.0' ENVIRONMENT_DISPLAY_NAME: 'Localhost' URI_SCHEME: '' FEEDBACK_EMAIL_ADDRESS: 'support@example.com' diff --git a/default_config/prod/config.yaml b/default_config/prod/config.yaml index f2868eb78..653fb81a0 100644 --- a/default_config/prod/config.yaml +++ b/default_config/prod/config.yaml @@ -1,5 +1,7 @@ API_HOST_URL: 'http://localhost:8000' APPLICATION_ID: 'org.openedx.app' +VERSION_CODE: 1 +VERSION_NAME: '1.0.0' ENVIRONMENT_DISPLAY_NAME: 'Localhost' URI_SCHEME: '' FEEDBACK_EMAIL_ADDRESS: 'support@example.com' diff --git a/default_config/stage/config.yaml b/default_config/stage/config.yaml index f2868eb78..653fb81a0 100644 --- a/default_config/stage/config.yaml +++ b/default_config/stage/config.yaml @@ -1,5 +1,7 @@ API_HOST_URL: 'http://localhost:8000' APPLICATION_ID: 'org.openedx.app' +VERSION_CODE: 1 +VERSION_NAME: '1.0.0' ENVIRONMENT_DISPLAY_NAME: 'Localhost' URI_SCHEME: '' FEEDBACK_EMAIL_ADDRESS: 'support@example.com'