diff --git a/.github/workflows/build_benchmark.yml b/.github/workflows/build_benchmark.yml index 0f6df78740..a8264a0697 100644 --- a/.github/workflows/build_benchmark.yml +++ b/.github/workflows/build_benchmark.yml @@ -83,7 +83,7 @@ jobs: uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2 - name: Build Benchmark app and run unit tests - run: ./gradlew assembleDevBenchmark testDevBenchmarkUnitTest testReleaseUnitTest --stacktrace + run: ./gradlew assembleDevBenchmark testDevBenchmarkUnitTest testReleaseUnitTest -Pandroid.signingConfig=debug --stacktrace - name: Upload artifacts uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 803b79cf73..00ab6b720b 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -82,7 +82,7 @@ jobs: echo "VERSION_TAG=$version_tag" >> $GITHUB_OUTPUT echo "COMMIT_COUNT=$commit_count" echo "COMMIT_COUNT=$commit_count" >> $GITHUB_OUTPUT - mv app/build/outputs/apk/standard/preview/app-standard-universal-preview-signed.apk Komikku-$version_tag-r$commit_count.apk + mv app/build/outputs/apk/standard/preview/app-standard-universal-preview-unsigned-signed.apk Komikku-$version_tag-r$commit_count.apk - name: Upload APK uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 diff --git a/.github/workflows/build_preview.yml b/.github/workflows/build_preview.yml index 13fac0ca11..739daaede5 100644 --- a/.github/workflows/build_preview.yml +++ b/.github/workflows/build_preview.yml @@ -192,23 +192,23 @@ jobs: run: | set -e - mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-universal-preview-signed.apk Komikku-${{ needs.prepare-build.outputs.TAG_NAME }}.apk + mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-universal-preview-unsigned-signed.apk Komikku-${{ needs.prepare-build.outputs.TAG_NAME }}.apk sha=`sha256sum Komikku-${{ needs.prepare-build.outputs.TAG_NAME }}.apk | awk '{ print $1 }'` echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_OUTPUT - mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-arm64-v8a-preview-signed.apk Komikku-arm64-v8a-${{ needs.prepare-build.outputs.TAG_NAME }}.apk + mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-arm64-v8a-preview-unsigned-signed.apk Komikku-arm64-v8a-${{ needs.prepare-build.outputs.TAG_NAME }}.apk sha=`sha256sum Komikku-arm64-v8a-${{ needs.prepare-build.outputs.TAG_NAME }}.apk | awk '{ print $1 }'` echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_OUTPUT - mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-armeabi-v7a-preview-signed.apk Komikku-armeabi-v7a-${{ needs.prepare-build.outputs.TAG_NAME }}.apk + mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-armeabi-v7a-preview-unsigned-signed.apk Komikku-armeabi-v7a-${{ needs.prepare-build.outputs.TAG_NAME }}.apk sha=`sha256sum Komikku-armeabi-v7a-${{ needs.prepare-build.outputs.TAG_NAME }}.apk | awk '{ print $1 }'` echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_OUTPUT - mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-x86-preview-signed.apk Komikku-x86-${{ needs.prepare-build.outputs.TAG_NAME }}.apk + mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-x86-preview-unsigned-signed.apk Komikku-x86-${{ needs.prepare-build.outputs.TAG_NAME }}.apk sha=`sha256sum Komikku-x86-${{ needs.prepare-build.outputs.TAG_NAME }}.apk | awk '{ print $1 }'` echo "APK_X86_SHA=$sha" >> $GITHUB_OUTPUT - mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-x86_64-preview-signed.apk Komikku-x86_64-${{ needs.prepare-build.outputs.TAG_NAME }}.apk + mv app/build/outputs/apk/${{ needs.prepare-build.outputs.ARTIFACTS_PREFIX }}-x86_64-preview-unsigned-signed.apk Komikku-x86_64-${{ needs.prepare-build.outputs.TAG_NAME }}.apk sha=`sha256sum Komikku-x86_64-${{ needs.prepare-build.outputs.TAG_NAME }}.apk | awk '{ print $1 }'` echo "APK_X86_64_SHA=$sha" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index e7496843de..21a6ae7e41 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -62,3 +62,32 @@ jobs: - name: Build app and run unit tests run: ./gradlew assembleStandardPreview testStandardPreviewUnitTest testReleaseUnitTest --stacktrace + + - name: Sign APK + uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 # v1 + with: + releaseDirectory: app/build/outputs/apk/standard/preview + signingKeyBase64: ${{ secrets.SIGNING_KEY }} + alias: ${{ secrets.ALIAS }} + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} + keyPassword: ${{ secrets.KEY_PASSWORD }} + + - name: Rename apk + id: current_commit + run: | + set -x + echo "The git ref is: ${{ github.ref }}" + version_tag=p$(echo ${{ github.ref }} | cut -d '/' -f 3) + commit_count=$(git rev-list --count HEAD) + echo "VERSION_TAG=$version_tag" + echo "VERSION_TAG=$version_tag" >> $GITHUB_OUTPUT + echo "COMMIT_COUNT=$commit_count" + echo "COMMIT_COUNT=$commit_count" >> $GITHUB_OUTPUT + mv app/build/outputs/apk/standard/preview/app-standard-universal-preview-unsigned-signed.apk Komikku-$version_tag-r$commit_count.apk + + - name: Upload APK + uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + with: + name: Komikku-${{ steps.current_commit.outputs.VERSION_TAG }}-r${{ steps.current_commit.outputs.COMMIT_COUNT }}.apk + path: ./*.apk + retention-days: 1 diff --git a/.gitignore b/.gitignore index 2329333dab..6ae03d5a86 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ CHANGELOG.md /captures build.sh /app/src/main/assets/client_secrets.json +*.jks diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4c6bea113b..b51523283e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -2,6 +2,8 @@ import mihon.buildlogic.getBuildTime import mihon.buildlogic.getCommitCount import mihon.buildlogic.getGitSha import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.io.FileInputStream +import java.util.Properties plugins { id("mihon.android.application") @@ -53,6 +55,15 @@ android { } } + signingConfigs { + create("preview") { + storeFile = rootProject.file(readPropertyFromLocalProperties("keystore") ?: "keystore.jks") + storePassword = readPropertyFromLocalProperties("storePassword") + keyAlias = readPropertyFromLocalProperties("keyAlias") + keyPassword = readPropertyFromLocalProperties("keyPassword") + } + } + buildTypes { named("debug") { versionNameSuffix = "-${getCommitCount()}" @@ -78,8 +89,8 @@ android { matchingFallbacks.add("release") versionNameSuffix = "-${getCommitCount()}" applicationIdSuffix = ".beta" - signingConfig = signingConfigs.getByName("debug") } + // Profilers build, overwrite dev's signing configuration by 'debug' key then re-sign with GitHub's workflow create("benchmark") { initWith(getByName("release")) @@ -100,6 +111,7 @@ android { flavorDimensions.add("default") productFlavors { + // Include Google service & build unsigned, for GitHub workflow build create("standard") { buildConfigField("boolean", "INCLUDE_UPDATER", "true") dimension = "default" @@ -107,10 +119,13 @@ android { create("fdroid") { dimension = "default" } + // Signed, dev build with Android Studio if it's not a debug build create("dev") { // Include pseudolocales: https://developer.android.com/guide/topics/resources/pseudolocales resourceConfigurations.addAll(listOf("en", "en_XA", "ar_XB", "xxhdpi")) dimension = "default" + // Default signing for dev flavor, would be overridden by buildTypes config + signingConfig = signingConfigs.getByName("preview") } } @@ -344,3 +359,16 @@ buildscript { classpath(kotlinx.gradle) } } + +// Config local store's signing key +fun readPropertyFromLocalProperties(propertyName: String): String? { + val localPropertiesFile = rootProject.file("local.properties") + if (localPropertiesFile.exists()) { + val properties = Properties() + FileInputStream(localPropertiesFile).use { inputStream -> + properties.load(inputStream) + } + return properties.getProperty(propertyName) + } + return null // Property not found +}