Skip to content

Build your personal knowledge base with Trilium Notes

fix(mobile): dedicated app ID and signing key for nightly builds (closes #10596)

Elian Doranedfb1ef28a16
diff --git a/.github/actions/build-mobile/action.yml b/.github/actions/build-mobile/action.yml
index d2bd03eda0..38f4996bdf 100644
--- a/.github/actions/build-mobile/action.yml
+++ b/.github/actions/build-mobile/action.yml
@@ -3,6 +3,29 @@ inputs:
description: "Whether to upload the APK as a workflow artifact"
required: false
default: "true"
+ nightly:
+ description: >-
+ Build the signed nightly variant: .nightly application ID suffix, release build
+ type, date-based versionCode, signed with the keystore inputs below. When false
+ (default), an unsigned debug APK (.debug application ID suffix) is built.
+ required: false
+ default: "false"
+ keystore-base64:
+ description: "Base64-encoded Android keystore used to sign the nightly APK"
+ required: false
+ default: ""
+ keystore-password:
+ description: "Password of the nightly keystore"
+ required: false
+ default: ""
+ key-alias:
+ description: "Alias of the signing key inside the nightly keystore"
+ required: false
+ default: ""
+ key-password:
+ description: "Password of the signing key"
+ required: false
+ default: ""
runs:
using: composite
steps:
@@ -38,16 +61,40 @@ runs:
shell: bash
run: pnpm --filter @triliumnext/mobile exec cap sync android
- - name: Assemble debug APK
+ - name: Prepare nightly signing
+ if: ${{ inputs.nightly == 'true' }}
+ shell: bash
+ env:
+ KEYSTORE_BASE64: ${{ inputs.keystore-base64 }}
+ KEYSTORE_PASSWORD: ${{ inputs.keystore-password }}
+ KEY_ALIAS: ${{ inputs.key-alias }}
+ KEY_PASSWORD: ${{ inputs.key-password }}
+ run: |
+ if [ -z "$KEYSTORE_BASE64" ] || [ -z "$KEYSTORE_PASSWORD" ] || [ -z "$KEY_ALIAS" ] || [ -z "$KEY_PASSWORD" ]; then
+ echo "::error::Nightly build requested but the signing inputs (keystore-base64, keystore-password, key-alias, key-password) are not all set."
+ exit 1
+ fi
+ printf '%s' "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/nightly.keystore"
+ {
+ echo "TRILIUM_NIGHTLY_BUILD=true"
+ echo "TRILIUM_ANDROID_KEYSTORE_PATH=$RUNNER_TEMP/nightly.keystore"
+ echo "TRILIUM_ANDROID_KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD"
+ echo "TRILIUM_ANDROID_KEY_ALIAS=$KEY_ALIAS"
+ echo "TRILIUM_ANDROID_KEY_PASSWORD=$KEY_PASSWORD"
+ echo "TRILIUM_ANDROID_VERSION_CODE=$(date -u +%Y%m%d)"
+ echo "TRILIUM_ANDROID_VERSION_NAME=nightly-$(date -u +%Y%m%d)"
+ } >> "$GITHUB_ENV"
+
+ - name: Assemble APK
shell: bash
working-directory: apps/mobile/android
- run: ./gradlew assembleDebug --no-daemon
+ run: ./gradlew ${{ inputs.nightly == 'true' && 'assembleRelease' || 'assembleDebug' }} --no-daemon
- name: Upload APK
if: ${{ inputs.upload-artifact == 'true' }}
uses: actions/upload-artifact@v7
with:
- name: trilium-mobile-debug-apk
- path: apps/mobile/android/app/build/outputs/apk/debug/*.apk
+ name: trilium-mobile-apk
+ path: apps/mobile/android/app/build/outputs/apk/**/*.apk
retention-days: 14
archive: false
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 1d88376af8..1ed5c3b298 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -120,6 +120,18 @@ jobs:
- name: Build mobile APK
uses: ./.github/actions/build-mobile
+ with:
+ nightly: "true"
+ upload-artifact: "false"
+ keystore-base64: ${{ secrets.NIGHTLY_ANDROID_KEYSTORE_BASE64 }}
+ keystore-password: ${{ secrets.NIGHTLY_ANDROID_KEYSTORE_PASSWORD }}
+ key-alias: ${{ secrets.NIGHTLY_ANDROID_KEY_ALIAS }}
+ key-password: ${{ secrets.NIGHTLY_ANDROID_KEY_PASSWORD }}
+
+ - name: Rename APK
+ run: >-
+ mv apps/mobile/android/app/build/outputs/apk/release/app-release.apk
+ apps/mobile/android/app/build/outputs/apk/release/TriliumNotes-mobile-nightly.apk
- name: Publish release
uses: softprops/[email protected]
@@ -127,7 +139,7 @@ jobs:
make_latest: false
prerelease: true
draft: false
- files: apps/mobile/android/app/build/outputs/apk/debug/*.apk
+ files: apps/mobile/android/app/build/outputs/apk/release/*.apk
tag_name: nightly
name: Mobile Nightly
diff --git a/apps/mobile/android/app/build.gradle b/apps/mobile/android/app/build.gradle
index a3921094f6..08886733c6 100644
--- a/apps/mobile/android/app/build.gradle
+++ b/apps/mobile/android/app/build.gradle
@@ -1,14 +1,23 @@
apply plugin: 'com.android.application'
+// Nightly builds get a dedicated application ID (side-by-side installable with a
+// future stable app) and are signed with the CI keystore. Set by the
+// .github/actions/build-mobile composite action; local builds are unaffected.
+def isNightly = System.getenv("TRILIUM_NIGHTLY_BUILD") == "true"
+def ciKeystorePath = System.getenv("TRILIUM_ANDROID_KEYSTORE_PATH")
+def ciVersionCode = (System.getenv("TRILIUM_ANDROID_VERSION_CODE") ?: "1").toInteger()
+def ciVersionName = System.getenv("TRILIUM_ANDROID_VERSION_NAME") ?: "1.0"
+
android {
namespace = "org.triliumnotes.trilium"
compileSdk = rootProject.ext.compileSdkVersion
defaultConfig {
- applicationId "org.triliumnotes.trilium"
+ applicationId "org.triliumnotes.trilium" + (isNightly ? ".nightly" : "")
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 1
- versionName "1.0"
+ versionCode ciVersionCode
+ versionName ciVersionName
+ manifestPlaceholders = [appName: isNightly ? "Trilium Nightly" : "Trilium Notes"]
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
@@ -16,10 +25,28 @@ android {
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
+ if (ciKeystorePath) {
+ signingConfigs {
+ ci {
+ storeFile file(ciKeystorePath)
+ storePassword System.getenv("TRILIUM_ANDROID_KEYSTORE_PASSWORD")
+ keyAlias System.getenv("TRILIUM_ANDROID_KEY_ALIAS")
+ keyPassword System.getenv("TRILIUM_ANDROID_KEY_PASSWORD")
+ }
+ }
+ }
buildTypes {
+ debug {
+ // Keeps unsigned/randomly-signed development and PR-artifact builds from
+ // ever conflicting with a nightly or stable install.
+ applicationIdSuffix ".debug"
+ }
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ if (ciKeystorePath) {
+ signingConfig signingConfigs.ci
+ }
}
}
}
diff --git a/apps/mobile/android/app/src/main/AndroidManifest.xml b/apps/mobile/android/app/src/main/AndroidManifest.xml
index e6c46ed49e..f8753a9601 100644
--- a/apps/mobile/android/app/src/main/AndroidManifest.xml
+++ b/apps/mobile/android/app/src/main/AndroidManifest.xml
@@ -5,7 +5,7 @@
android:allowBackup="true"
android:largeHeap="true"
android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
+ android:label="${appName}"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
@@ -15,7 +15,7 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
android:windowSoftInputMode="adjustResize"
android:name=".MainActivity"
- android:label="@string/title_activity_main"
+ android:label="${appName}"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">