diff --git a/.github/workflows/Build-Apk.yml b/.github/workflows/Build-Apk.yml index b3db27e7a..4762e5db9 100644 --- a/.github/workflows/Build-Apk.yml +++ b/.github/workflows/Build-Apk.yml @@ -7,9 +7,6 @@ on: branches: - '**' -env: - BUGLY_TOKEN: ${{ secrets.BUGLY_TOKEN }} - jobs: build: if: ${{ !startsWith(github.event.head_commit.message, 'chore:') }} @@ -32,6 +29,15 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- + - name: write secrets info + run: | + echo GKD_BUGLY_APP_ID='${{ secrets.GKD_BUGLY_APP_ID }}' >> gradle.properties + echo ${{ secrets.GKD_STORE_FILE_BASE64 }} | base64 --decode > ${{ github.workspace }}/key.jks + echo GKD_STORE_FILE='${{ github.workspace }}/key.jks' >> gradle.properties + echo GKD_STORE_PASSWORD='${{ secrets.GKD_STORE_PASSWORD }}' >> gradle.properties + echo GKD_KEY_ALIAS='${{ secrets.GKD_KEY_ALIAS }}' >> gradle.properties + echo GKD_KEY_PASSWORD='${{ secrets.GKD_KEY_PASSWORD }}' >> gradle.properties + - run: chmod 777 ./gradlew - run: ./gradlew build diff --git a/.github/workflows/Build-Release.yml b/.github/workflows/Build-Release.yml index 4c837cbe1..e4ce9a14a 100644 --- a/.github/workflows/Build-Release.yml +++ b/.github/workflows/Build-Release.yml @@ -5,9 +5,6 @@ on: tags: - v* -env: - BUGLY_TOKEN: ${{ secrets.BUGLY_TOKEN }} - jobs: build: runs-on: ubuntu-latest @@ -29,6 +26,15 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- + - name: write secrets info + run: | + echo GKD_BUGLY_APP_ID='${{ secrets.GKD_BUGLY_APP_ID }}' >> gradle.properties + echo ${{ secrets.GKD_STORE_FILE_BASE64 }} | base64 --decode > ${{ github.workspace }}/key.jks + echo GKD_STORE_FILE='${{ github.workspace }}/key.jks' >> gradle.properties + echo GKD_STORE_PASSWORD='${{ secrets.GKD_STORE_PASSWORD }}' >> gradle.properties + echo GKD_KEY_ALIAS='${{ secrets.GKD_KEY_ALIAS }}' >> gradle.properties + echo GKD_KEY_PASSWORD='${{ secrets.GKD_KEY_PASSWORD }}' >> gradle.properties + - run: chmod 777 ./gradlew - run: ./gradlew build diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3dbbb32d7..e4cef1570 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -40,7 +40,7 @@ android { ) ) buildConfigField( - "String", "BUGLY_TOKEN", jsonStringOf(System.getenv("BUGLY_TOKEN")) + "String", "GKD_BUGLY_APP_ID", jsonStringOf(project.properties["GKD_BUGLY_APP_ID"]) ) resourceConfigurations.addAll(listOf("zh", "en")) @@ -54,18 +54,22 @@ android { disable.add("ModifierFactoryUnreferencedReceiver") } - signingConfigs { - create("release") { - storeFile = file("./android.jks") - storePassword = "KdMQ6pqiNSJ6Sype" - keyAlias = "key0" - keyPassword = "KdMQ6pqiNSJ6Sype" + val currentSigning = if (project.hasProperty("GKD_STORE_FILE")) { + signingConfigs.create("release") { + storeFile = file(project.properties["GKD_STORE_FILE"] as String) + storePassword = project.properties["GKD_STORE_PASSWORD"] as String + keyAlias = project.properties["GKD_KEY_ALIAS"] as String + keyPassword = project.properties["GKD_KEY_PASSWORD"] as String } + } else { + signingConfigs.getByName("debug") } buildTypes { + all { + signingConfig = currentSigning + } release { - signingConfig = signingConfigs.getByName("release") isMinifyEnabled = true isShrinkResources = true setProguardFiles( @@ -77,7 +81,6 @@ android { } debug { applicationIdSuffix = ".debug" - signingConfig = signingConfigs.getByName("release") resValue("string", "app_name", "GKD-debug") } } diff --git a/app/src/main/java/li/songe/gkd/App.kt b/app/src/main/java/li/songe/gkd/App.kt index 9c13cbf8a..c0612fcb7 100644 --- a/app/src/main/java/li/songe/gkd/App.kt +++ b/app/src/main/java/li/songe/gkd/App.kt @@ -39,11 +39,11 @@ class App : Application() { super.onCreate() _app = this - @Suppress("SENSELESS_COMPARISON") if (BuildConfig.BUGLY_TOKEN != null) { + @Suppress("SENSELESS_COMPARISON") if (BuildConfig.GKD_BUGLY_APP_ID != null) { CrashReport.setDeviceModel(this, DeviceInfo.instance.model) CrashReport.setIsDevelopmentDevice(this, BuildConfig.DEBUG) CrashReport.initCrashReport(applicationContext, - BuildConfig.BUGLY_TOKEN, + BuildConfig.GKD_BUGLY_APP_ID, BuildConfig.DEBUG, CrashReport.UserStrategy(this).apply { setCrashHandleCallback(object : CrashReport.CrashHandleCallback() {