Skip to content

Commit

Permalink
Use a new way to sign apk
Browse files Browse the repository at this point in the history
  • Loading branch information
Super12138 committed Apr 10, 2024
1 parent d4799ab commit 5af61ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/android_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Write sign info
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.repository == 'Super12138/ToDo'
run: |
if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
echo releaseStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
echo releaseKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
echo releaseKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
echo releaseStoreFile='${{ github.workspace }}/key.jks' >> gradle.properties
echo ${{ secrets.SIGNING_KEY }} | base64 --decode > ${{ github.workspace }}/key.jks
fi
- name: Build with Gradle
run: ./gradlew assembleRelease

- uses: ilharp/sign-android-release@nightly
name: Sign APK
id: sign_app
with:
releaseDir: app/build/outputs/apk/release
signingKey: ${{ secrets.ANDROID_SIGNING_KEY }}
keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}
buildToolsVersion: 33.0.0

- name: Upload APK
uses: actions/[email protected]
with:
Expand Down
13 changes: 13 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ android {
namespace = "cn.super12138.todo"
compileSdk = 34

// 获取 Release 签名
val releaseSigning = if (project.hasProperty("releaseStoreFile")) {
signingConfigs.create("release") {
storeFile = File(project.properties["releaseStoreFile"] as String)
storePassword = project.properties["releaseStorePassword"] as String
keyAlias = project.properties["releaseKeyAlias"] as String
keyPassword = project.properties["releaseKeyPassword"] as String
}
} else {
signingConfigs.getByName("debug")
}

defaultConfig {
applicationId = "cn.super12138.todo"
minSdk = 24
Expand All @@ -29,6 +41,7 @@ android {

buildTypes {
release {
signingConfig = releaseSigning
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true

0 comments on commit 5af61ff

Please sign in to comment.