Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,26 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build app module (release)
- name: Build app module (debug)
if: env.BUILD_APP == 'true'
run: ./gradlew :app:assembleRelease
run: ./gradlew :app:assembleDebug

- name: Build humanoperator module (release)
- name: Build humanoperator module (debug)
if: env.BUILD_HUMANOPERATOR == 'true'
run: ./gradlew :humanoperator:assembleRelease
run: ./gradlew :humanoperator:assembleDebug

- name: Upload app APK
if: env.BUILD_APP == 'true'
uses: actions/upload-artifact@v4
with:
name: app-release-unsigned
path: app/build/outputs/apk/release/app-release-unsigned.apk

name: app-debug
path: app/build/outputs/apk/debug/app-debug.apk
- name: Upload humanoperator APK
if: env.BUILD_HUMANOPERATOR == 'true'
uses: actions/upload-artifact@v4
with:
name: humanoperator-release-unsigned
path: humanoperator/build/outputs/apk/release/humanoperator-release-unsigned.apk

name: humanoperator-debug
path: humanoperator/build/outputs/apk/debug/humanoperator-debug.apk
- name: Build summary
run: |
echo "### Build Summary" >> $GITHUB_STEP_SUMMARY
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ Free models accessible via an API can be found [here](https://github.com/cheahjs
If you in your Google account identified as under 18, you need an adult account because Google is (unreasonably) denying you the API key.

Preview models will eventually be removed by Google and unfortunately won't be redirected to finished equivalents. If this happens, please change the API in the code.

## CI Release Signing

Dokumentation für CI-Secrets und Verhalten bei fehlender Signing-Konfiguration: [docs/ci-signing.md](docs/ci-signing.md)
37 changes: 36 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
Expand All @@ -14,6 +13,23 @@ System.getenv("SCREENOPERATOR_BUILD_DIR")?.takeIf { it.isNotBlank() }?.let { cus
layout.buildDirectory = file(customBuildDir)
}

val releaseSigningEnv = mapOf(
"ANDROID_KEYSTORE_PATH" to System.getenv("ANDROID_KEYSTORE_PATH"),
"ANDROID_KEY_ALIAS" to System.getenv("ANDROID_KEY_ALIAS"),
"ANDROID_KEYSTORE_PASSWORD" to System.getenv("ANDROID_KEYSTORE_PASSWORD"),
"ANDROID_KEY_PASSWORD" to System.getenv("ANDROID_KEY_PASSWORD"),
Comment on lines +17 to +20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: Passwords in environment variables will be logged in Gradle build outputs1. Replace direct password access with secure property file handling or Gradle's built-in secrets management. At minimum, ensure CI systems mask these variables in logs.

Footnotes

  1. CWE-532: Insertion of Sensitive Information into Log File - https://cwe.mitre.org/data/definitions/532.html

)

val missingReleaseSigningEnv = releaseSigningEnv
.filterValues { it.isNullOrBlank() }
.keys

val isReleaseTaskRequested = gradle.startParameter.taskNames.any { task ->
task.contains("release", ignoreCase = true)
}

val missingReleaseSigningEnvText = missingReleaseSigningEnv.joinToString(separator = ", ")

android {
namespace = "com.google.ai.sample"
compileSdk = 35
Expand All @@ -34,12 +50,24 @@ android {
}
}

signingConfigs {
create("release") {
if (missingReleaseSigningEnv.isEmpty()) {
storeFile = file(releaseSigningEnv.getValue("ANDROID_KEYSTORE_PATH")!!)
storePassword = releaseSigningEnv.getValue("ANDROID_KEYSTORE_PASSWORD")
keyAlias = releaseSigningEnv.getValue("ANDROID_KEY_ALIAS")
keyPassword = releaseSigningEnv.getValue("ANDROID_KEY_PASSWORD")
}
}
}

buildTypes {
getByName("debug") {
isDebuggable = true
}
getByName("release") {
isDebuggable = false
signingConfig = if (missingReleaseSigningEnv.isEmpty()) signingConfigs.getByName("release") else null
}
create("samples") {
initWith(getByName("debug"))
Expand Down Expand Up @@ -67,6 +95,13 @@ android {
}
}

if (isReleaseTaskRequested && missingReleaseSigningEnv.isNotEmpty()) {
error(
"Release signing env vars missing for module :app: ${missingReleaseSigningEnvText}. " +
"Set ANDROID_KEYSTORE_PATH, ANDROID_KEY_ALIAS, ANDROID_KEYSTORE_PASSWORD and ANDROID_KEY_PASSWORD."
)
}

dependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.20")
Expand Down
19 changes: 19 additions & 0 deletions docs/ci-signing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CI Signing für Release-Builds

Die Module `app` und `humanoperator` erwarten für Release-Tasks eine Signing-Konfiguration über Umgebungsvariablen.

## Benötigte CI-Secrets

- `ANDROID_KEYSTORE_PATH`: Absoluter oder relativ zum Projekt auflösbarer Pfad zur Keystore-Datei.
- `ANDROID_KEY_ALIAS`: Alias des Release-Keys.
- `ANDROID_KEYSTORE_PASSWORD`: Passwort der Keystore-Datei.
- `ANDROID_KEY_PASSWORD`: Passwort des Keys.

## Verhalten bei fehlenden Variablen

- Für **Release-Tasks** (Taskname enthält `release`) wird der Build mit einer klaren Fehlermeldung abgebrochen, wenn eine der Variablen fehlt.
- Für Nicht-Release-Tasks bleibt die Signing-Config ungesetzt, damit lokale Debug-Builds weiter funktionieren.

## Wichtiger Hinweis zu Firebase

`google-services.json` bleibt unverändert versioniert und ist **nicht** Teil der Signing-Logik.
36 changes: 36 additions & 0 deletions humanoperator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ plugins {
id("com.google.gms.google-services")
}

val releaseSigningEnv = mapOf(
"ANDROID_KEYSTORE_PATH" to System.getenv("ANDROID_KEYSTORE_PATH"),
"ANDROID_KEY_ALIAS" to System.getenv("ANDROID_KEY_ALIAS"),
"ANDROID_KEYSTORE_PASSWORD" to System.getenv("ANDROID_KEYSTORE_PASSWORD"),
"ANDROID_KEY_PASSWORD" to System.getenv("ANDROID_KEY_PASSWORD"),
Comment on lines +8 to +11
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: Passwords in environment variables will be logged in Gradle build outputs1. Replace direct password access with secure property file handling or Gradle's built-in secrets management. At minimum, ensure CI systems mask these variables in logs.

Footnotes

  1. CWE-532: Insertion of Sensitive Information into Log File - https://cwe.mitre.org/data/definitions/532.html

)

val missingReleaseSigningEnv = releaseSigningEnv
.filterValues { it.isNullOrBlank() }
.keys

val isReleaseTaskRequested = gradle.startParameter.taskNames.any { task ->
task.contains("release", ignoreCase = true)
}

val missingReleaseSigningEnvText = missingReleaseSigningEnv.joinToString(separator = ", ")

android {
namespace = "com.screenoperator.humanoperator"
compileSdk = 35
Expand All @@ -21,10 +38,22 @@ android {
}
}

signingConfigs {
create("release") {
if (missingReleaseSigningEnv.isEmpty()) {
storeFile = file(releaseSigningEnv.getValue("ANDROID_KEYSTORE_PATH")!!)
storePassword = releaseSigningEnv.getValue("ANDROID_KEYSTORE_PASSWORD")
keyAlias = releaseSigningEnv.getValue("ANDROID_KEY_ALIAS")
keyPassword = releaseSigningEnv.getValue("ANDROID_KEY_PASSWORD")
}
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = if (missingReleaseSigningEnv.isEmpty()) signingConfigs.getByName("release") else null
}
}

Expand All @@ -43,6 +72,13 @@ android {
}
}

if (isReleaseTaskRequested && missingReleaseSigningEnv.isNotEmpty()) {
error(
"Release signing env vars missing for module :humanoperator: ${missingReleaseSigningEnvText}. " +
"Set ANDROID_KEYSTORE_PATH, ANDROID_KEY_ALIAS, ANDROID_KEYSTORE_PASSWORD and ANDROID_KEY_PASSWORD."
)
}

dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
Expand Down
Loading