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 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 {

View File

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

View File

@ -48,6 +48,7 @@ ANDROID_APK_SIGNED=true
org.gradle.jvmargs=-Xmx8704M
versionCode=9999
commitHash=unknown
# Flipper
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 {
agent { label 'linux' }

View File

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

View File

@ -1,4 +1,4 @@
library 'status-jenkins-lib@v1.2.18'
library 'status-jenkins-lib@v1.3.2'
pipeline {
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 {
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 {
agent { label 'macos' }

View File

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

View File

@ -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

View File

@ -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

View File

@ -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)\";"