ci: build signed apk

Co-authored-by: MinoriceOwO <154642983+minoriceowo@users.noreply.github.com>
This commit is contained in:
BinTianqi
2024-05-25 14:14:12 +08:00
parent f9ff27446e
commit acf3cb6b81
3 changed files with 67 additions and 11 deletions

View File

@@ -26,20 +26,41 @@ jobs:
- name: Grant execution permission to Gradle Wrapper
run: chmod +x gradlew
- name: Build Debug APK
run: ./gradlew assembleDebug
- name: Build APK (testkey)
run: ./gradlew build
- name: Upload Debug APK
- name: Upload Debug APK (testkey)
uses: actions/upload-artifact@v4
with:
name: OwnDroid-CI-${{ env.SHORT_SHA }}-debug-testkey.apk
path: app/build/outputs/apk/debug/app-debug.apk
- name: Build Release APK
run: ./gradlew assembleRelease
- name: Upload Release APK
- name: Upload Release APK (testkey)
uses: actions/upload-artifact@v4
with:
name: OwnDroid-CI-${{ env.SHORT_SHA }}-release-testkey.apk
path: app/build/outputs/apk/release/app-release.apk
- name: Export key
env:
KEY_BASE64: ${{ secret.KEY_BASE64 }}
run: echo $KEY_BASE64 | base64 --decode - > app/signature.jks
- name: Build APK
env:
KEYSTORE_PASSWORD: ${{ secret.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secret.KEY_PASSWORD }}
KEY_ALIAS: ${{ secret.KEY_ALIAS }}
run: ./gradlew build
- name: Upload Debug APK
uses: actions/upload-artifact@v4
with:
name: OwnDroid-CI-${{ env.SHORT_SHA }}-debug-signed.apk
path: app/build/outputs/apk/debug/app-debug.apk
- name: Upload Release APK
uses: actions/upload-artifact@v4
with:
name: OwnDroid-CI-${{ env.SHORT_SHA }}-release-signed.apk
path: app/build/outputs/apk/debug/app-debug.apk

1
.gitignore vendored
View File

@@ -10,4 +10,5 @@ captures
app/build
app/release
app/debug
app/signature.jks
.androidide

View File

@@ -3,19 +3,24 @@ plugins {
alias(libs.plugins.kotlin.android)
}
var keyPassword: String? = null
var keystorePassword: String? = null
var keyAlias: String? = null
android {
signingConfigs {
create("testkey") {
storeFile = file("testkey.jks")
storePassword = "testkey"
keyPassword = "testkey"
keyAlias = "testkey"
storeFile = file("signature.jks")
storePassword = keystorePassword ?: "testkey"
keyPassword = keyPassword ?: "testkey"
keyAlias = keyAlias ?: "testkey"
}
}
namespace = "com.bintianqi.owndroid"
compileSdk = 34
lint.checkReleaseBuilds = false
lint.disable += "All"
defaultConfig {
applicationId = "com.bintianqi.owndroid"
@@ -68,6 +73,35 @@ android {
}
}
gradle.taskGraph.whenReady {
project.tasks.findByPath(":app:test")?.enabled = false
project.tasks.findByPath(":app:lint")?.enabled = false
project.tasks.findByPath(":app:lintAnalyzeDebug")?.enabled = false
}
tasks.findByName("preBuild")?.dependsOn?.plusAssign("prepareSignature")
tasks.register("prepareSignature") {
doFirst {
file("signature.jks").let {
if(!it.exists()) file("testkey.jks").copyTo(it)
}
keystorePassword = System.getenv("KEYSTORE_PASSWORD")
keyAlias = System.getenv("KEY_ALIAS")
keyPassword = System.getenv("KEY_PASSWORD")
}
}
tasks.findByName("clean")?.dependsOn?.plusAssign("cleanKey")
tasks.register("cleanKey") {
doFirst {
file("signature.jks").let {
if(it.exists()) it.delete()
}
}
}
dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.ui)