Skip to content

Commit

Permalink
signing key for dev-preview
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong-tran committed Jul 9, 2024
1 parent 0496c60 commit 8efbd22
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/build_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ CHANGELOG.md
/captures
build.sh
/app/src/main/assets/client_secrets.json
*.jks
30 changes: 29 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()}"
Expand All @@ -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"))

Expand All @@ -100,17 +111,21 @@ android {
flavorDimensions.add("default")

productFlavors {
// Include Google service & build unsigned, for GitHub workflow build
create("standard") {
buildConfigField("boolean", "INCLUDE_UPDATER", "true")
dimension = "default"
}
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")
}
}

Expand Down Expand Up @@ -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
}

0 comments on commit 8efbd22

Please sign in to comment.