diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index c5e0f04e..7a437a25 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -35,18 +35,21 @@ jobs: - name: Decode Keystore run: echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 --decode > app/release.keystore - - name: Build Default Release APK + - name: Build Release APKs run: | - ./gradlew assembleDefaultRelease \ + ./gradlew assembleDefaultRelease assembleSamsungRelease assembleMeituRelease \ -PRELEASE_STORE_FILE=release.keystore \ -PRELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} \ -PRELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} \ -PRELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} - - name: Upload Default Release APK to GitHub Release + - name: Upload Release APKs to GitHub Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: - files: app/build/outputs/apk/default/release/*.apk + files: | + app/build/outputs/apk/default/release/*.apk + app/build/outputs/apk/samsung/release/*.apk + app/build/outputs/apk/meitu/release/*.apk env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a06b0c8d..1e899aa4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -113,6 +113,20 @@ android { localProperties.getProperty("BUILT_IN_API_KEY", "").toBuildConfigString() ) } + create("meitu") { + dimension = "channel" + applicationId = "com.meitu.meiyancamera" + buildConfigField( + "String", + "BUILT_IN_API_URL", + "https://token-plan-cn.xiaomimimo.com/v1".toBuildConfigString() + ) + buildConfigField( + "String", + "BUILT_IN_API_KEY", + localProperties.getProperty("BUILT_IN_API_KEY", "").toBuildConfigString() + ) + } } compileOptions { @@ -136,6 +150,12 @@ android { } manifest.srcFile("src/default/AndroidManifest.xml") } + getByName("meitu") { + java { + srcDir("src/default/java") + } + manifest.srcFile("src/default/AndroidManifest.xml") + } } externalNativeBuild { diff --git a/app/src/default/java/com/hinnka/mycamera/update/AppUpdateManager.kt b/app/src/default/java/com/hinnka/mycamera/update/AppUpdateManager.kt index b637c08f..70e2d225 100644 --- a/app/src/default/java/com/hinnka/mycamera/update/AppUpdateManager.kt +++ b/app/src/default/java/com/hinnka/mycamera/update/AppUpdateManager.kt @@ -56,11 +56,15 @@ object AppUpdateManager { private val _readyApk = MutableStateFlow(null) val readyApk: StateFlow = _readyApk.asStateFlow() - suspend fun checkForUpdate(currentVersion: String = BuildConfig.VERSION_NAME): AppUpdateRelease? = + suspend fun checkForUpdate( + currentVersion: String = BuildConfig.VERSION_NAME, + flavor: String = BuildConfig.FLAVOR + ): AppUpdateRelease? = withContext(Dispatchers.IO) { val encodedVersion = URLEncoder.encode(currentVersion, "UTF-8") + val encodedFlavor = URLEncoder.encode(flavor, "UTF-8") val request = Request.Builder() - .url("$VERSION_CHECK_URL?current_version=$encodedVersion") + .url("$VERSION_CHECK_URL?current_version=$encodedVersion&flavor=$encodedFlavor") .get() .build() @@ -75,7 +79,7 @@ object AppUpdateManager { PLog.d(TAG, "version: $body") val root = JSONObject(body) if (!root.optBoolean("has_update", false)) { - PLog.d(TAG, "No update available: current=$currentVersion") + PLog.d(TAG, "No update available: current=$currentVersion, flavor=$flavor") return@withContext null } @@ -85,7 +89,7 @@ object AppUpdateManager { val isApkAsset = assetName.endsWith(".apk", ignoreCase = true) || downloadUrl.substringBefore("?").endsWith(".apk", ignoreCase = true) if (downloadUrl.isBlank() || !isApkAsset) { - PLog.w(TAG, "Update found but APK asset is missing") + PLog.w(TAG, "Update found but APK asset is missing: flavor=$flavor") return@withContext null } val versionName = root.optString("latest_version")