From e2c18ea151327d3999cb85d3a57357c2e6db8179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 17 Sep 2021 18:04:39 +0200 Subject: [PATCH] add commit hash to app metadata for Android and iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will make identifying installed software easier. It can also be used to generate F-Droid RPs more easily. Depends on: https://github.com/status-im/status-jenkins-lib/pull/35 Signed-off-by: Jakub SokoĊ‚owski --- android/app/build.gradle | 8 ++++++++ android/app/src/main/AndroidManifest.xml | 1 + android/gradle.properties | 1 + ci/Jenkinsfile.android | 2 +- ci/Jenkinsfile.combined | 2 +- ci/Jenkinsfile.ios | 2 +- ci/Jenkinsfile.nix-cache | 2 +- ci/tools/Jenkinsfile.fastlane-clean | 2 +- ios/StatusIm/Info.plist | 2 ++ nix/config.nix | 1 + nix/mobile/android/release.nix | 2 ++ scripts/release-android.sh | 1 + 12 files changed, 21 insertions(+), 5 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 95ccbe25ec..d5babfa56e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -128,6 +128,13 @@ def enableHermes = project.ext.react.get("enableHermes", false); */ def googleFree = project.env.get("GOOGLE_FREE", false) +def getCommitHash = { -> + if (project.hasProperty("commitHash")) { + return project.commitHash + } + return "unknown" +} + def getVersionCode = { -> new ByteArrayOutputStream().withStream { stdOut -> if (project.hasProperty("versionCode")) { @@ -184,6 +191,7 @@ android { versionCode getVersionCode() versionName getVersionName() missingDimensionStrategy 'react-native-camera', 'general' + manifestPlaceholders = [commitHash: getCommitHash()] /* this needs to be empty if we want APKs split by ABIs */ if (!getEnvOrConfig('ANDROID_ABI_SPLIT').toBoolean()) { ndk { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7728f9a98f..6c53ecda89 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -33,6 +33,7 @@ android:name=".MainApplication" android:largeHeap="true" android:usesCleartextTraffic="true"> + CFBundleBuildUrl ???? + CFBundleCommitHash + unknown NSFaceIDUsageDescription Enabling Face ID allows you quick and secure access to your account. CFBundleDevelopmentRegion diff --git a/nix/config.nix b/nix/config.nix index 88a9addacd..b8b34c232a 100644 --- a/nix/config.nix +++ b/nix/config.nix @@ -3,6 +3,7 @@ status-im = { build-type = "pr"; # Build type (influences which .env file gets used for feature flags) build-number = 9999; # Used for versionCode and CFBundleVersion in Android and iOS respectively + commit-hash = "unknown"; # Included in APK Manifest for easier identification. android = { gradle-opts = null; # Gradle options passed for Android builds diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/release.nix index 1d165c7af8..a45d34021b 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/release.nix @@ -24,6 +24,7 @@ let buildType = getConfig "build-type" "release"; buildNumber = getConfig "build-number" 9999; + commitHash = getConfig "commit-hash" "unknown"; gradleOpts = getConfig "android.gradle-opts" null; # Used to detect end-to-end builds androidAbiInclude = getConfig "android.abi-include" "armeabi-v7a;arm64-v8a;x86"; @@ -153,6 +154,7 @@ in stdenv.mkDerivation rec { -Dorg.gradle.daemon=false \ -Dmaven.repo.local='${deps.gradle}' \ -PversionCode=${toString buildNumber} \ + -PcommitHash=${commitHash} \ assemble${gradleBuildType} \ || exit 1 popd > /dev/null diff --git a/scripts/release-android.sh b/scripts/release-android.sh index fbe464fba2..4ba611b8dd 100755 --- a/scripts/release-android.sh +++ b/scripts/release-android.sh @@ -32,6 +32,7 @@ fi if [[ "${ANDROID_APK_SIGNED}" == "true" ]]; then config+="status-im.android.keystore-path=\"$(must_get_env KEYSTORE_PATH)\";" fi +config+="status-im.commit-hash=\"$(git rev-parse --verify HEAD)\";" config+="status-im.build-type=\"$(must_get_env BUILD_TYPE)\";" config+="status-im.build-number=\"$(must_get_env BUILD_NUMBER)\";" config+="status-im.android.apk-signed=\"$(must_get_env ANDROID_APK_SIGNED)\";"