Use a new way to sign apk

This commit is contained in:
Super12138 2024-04-10 20:02:52 +08:00
parent d4799ab6f2
commit 5af61ff97b
3 changed files with 26 additions and 12 deletions

View file

@ -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/upload-artifact@v4.3.1
with:

View file

@ -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
@ -29,6 +41,7 @@ android {
buildTypes {
release {
signingConfig = releaseSigning
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(

View file

@ -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