add commit hash to app metadata for Android and iOS

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 <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2021-09-17 18:04:39 +02:00
parent 82b640abe1
commit e2c18ea151
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
12 changed files with 21 additions and 5 deletions

View File

@ -128,6 +128,13 @@ def enableHermes = project.ext.react.get("enableHermes", false);
*/ */
def googleFree = project.env.get("GOOGLE_FREE", false) def googleFree = project.env.get("GOOGLE_FREE", false)
def getCommitHash = { ->
if (project.hasProperty("commitHash")) {
return project.commitHash
}
return "unknown"
}
def getVersionCode = { -> def getVersionCode = { ->
new ByteArrayOutputStream().withStream { stdOut -> new ByteArrayOutputStream().withStream { stdOut ->
if (project.hasProperty("versionCode")) { if (project.hasProperty("versionCode")) {
@ -184,6 +191,7 @@ android {
versionCode getVersionCode() versionCode getVersionCode()
versionName getVersionName() versionName getVersionName()
missingDimensionStrategy 'react-native-camera', 'general' missingDimensionStrategy 'react-native-camera', 'general'
manifestPlaceholders = [commitHash: getCommitHash()]
/* this needs to be empty if we want APKs split by ABIs */ /* this needs to be empty if we want APKs split by ABIs */
if (!getEnvOrConfig('ANDROID_ABI_SPLIT').toBoolean()) { if (!getEnvOrConfig('ANDROID_ABI_SPLIT').toBoolean()) {
ndk { ndk {

View File

@ -33,6 +33,7 @@
android:name=".MainApplication" android:name=".MainApplication"
android:largeHeap="true" android:largeHeap="true"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<meta-data android:name="commitHash" android:value="${commitHash}"/>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"

View File

@ -48,6 +48,7 @@ ANDROID_APK_SIGNED=true
org.gradle.jvmargs=-Xmx8704M org.gradle.jvmargs=-Xmx8704M
versionCode=9999 versionCode=9999
commitHash=unknown
# Flipper # Flipper
FLIPPER_VERSION=0.54.0 FLIPPER_VERSION=0.54.0

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.2.18' library 'status-jenkins-lib@v1.3.2'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.2.18' library 'status-jenkins-lib@v1.3.2'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.2.18' library 'status-jenkins-lib@v1.3.2'
pipeline { pipeline {
agent { label 'macos-xcode-12.5' } agent { label 'macos-xcode-12.5' }

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.2.18' library 'status-jenkins-lib@v1.3.2'
pipeline { pipeline {
agent { label params.AGENT_LABEL } agent { label params.AGENT_LABEL }

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.2.18' library 'status-jenkins-lib@v1.3.2'
pipeline { pipeline {
agent { label 'macos' } agent { label 'macos' }

View File

@ -4,6 +4,8 @@
<dict> <dict>
<key>CFBundleBuildUrl</key> <key>CFBundleBuildUrl</key>
<string>????</string> <string>????</string>
<key>CFBundleCommitHash</key>
<string>unknown</string>
<key>NSFaceIDUsageDescription</key> <key>NSFaceIDUsageDescription</key>
<string>Enabling Face ID allows you quick and secure access to your account.</string> <string>Enabling Face ID allows you quick and secure access to your account.</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>

View File

@ -3,6 +3,7 @@
status-im = { status-im = {
build-type = "pr"; # Build type (influences which .env file gets used for feature flags) 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 build-number = 9999; # Used for versionCode and CFBundleVersion in Android and iOS respectively
commit-hash = "unknown"; # Included in APK Manifest for easier identification.
android = { android = {
gradle-opts = null; # Gradle options passed for Android builds gradle-opts = null; # Gradle options passed for Android builds

View File

@ -24,6 +24,7 @@ let
buildType = getConfig "build-type" "release"; buildType = getConfig "build-type" "release";
buildNumber = getConfig "build-number" 9999; buildNumber = getConfig "build-number" 9999;
commitHash = getConfig "commit-hash" "unknown";
gradleOpts = getConfig "android.gradle-opts" null; gradleOpts = getConfig "android.gradle-opts" null;
# Used to detect end-to-end builds # Used to detect end-to-end builds
androidAbiInclude = getConfig "android.abi-include" "armeabi-v7a;arm64-v8a;x86"; androidAbiInclude = getConfig "android.abi-include" "armeabi-v7a;arm64-v8a;x86";
@ -153,6 +154,7 @@ in stdenv.mkDerivation rec {
-Dorg.gradle.daemon=false \ -Dorg.gradle.daemon=false \
-Dmaven.repo.local='${deps.gradle}' \ -Dmaven.repo.local='${deps.gradle}' \
-PversionCode=${toString buildNumber} \ -PversionCode=${toString buildNumber} \
-PcommitHash=${commitHash} \
assemble${gradleBuildType} \ assemble${gradleBuildType} \
|| exit 1 || exit 1
popd > /dev/null popd > /dev/null

View File

@ -32,6 +32,7 @@ fi
if [[ "${ANDROID_APK_SIGNED}" == "true" ]]; then if [[ "${ANDROID_APK_SIGNED}" == "true" ]]; then
config+="status-im.android.keystore-path=\"$(must_get_env KEYSTORE_PATH)\";" config+="status-im.android.keystore-path=\"$(must_get_env KEYSTORE_PATH)\";"
fi 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-type=\"$(must_get_env BUILD_TYPE)\";"
config+="status-im.build-number=\"$(must_get_env BUILD_NUMBER)\";" config+="status-im.build-number=\"$(must_get_env BUILD_NUMBER)\";"
config+="status-im.android.apk-signed=\"$(must_get_env ANDROID_APK_SIGNED)\";" config+="status-im.android.apk-signed=\"$(must_get_env ANDROID_APK_SIGNED)\";"