diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18a424902..f88bda554 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -221,7 +221,7 @@ jobs: uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 with: name: com.bitwarden.authenticator.aab - path: authenticator/build/outputs/bundle/release/com.bitwarden.authenticator-release.aab + path: authenticator/build/outputs/bundle/release/com.bitwarden.authenticator.aab if-no-files-found: error - name: Upload release .apk artifact @@ -229,19 +229,19 @@ jobs: uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0 with: name: com.bitwarden.authenticator.apk - path: authenticator/build/outputs/apk/release/com.bitwarden.authenticator-release.apk + path: authenticator/build/outputs/apk/release/com.bitwarden.authenticator.apk if-no-files-found: error - name: Create checksum file for Release AAB if: ${{ matrix.variant == 'aab' }} run: | - sha256sum "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator-release.aab" \ + sha256sum "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator.aab" \ > ./authenticator-android-aab-sha256.txt - name: Create checksum for release .apk artifact if: ${{ matrix.variant == 'apk' }} run: | - sha256sum "authenticator/build/outputs/apk/release/com.bitwarden.authenticator-release.apk" \ + sha256sum "authenticator/build/outputs/apk/release/com.bitwarden.authenticator.apk" \ > ./authenticator-android-apk-sha256.txt - name: Upload .apk SHA file for release diff --git a/authenticator/build.gradle.kts b/authenticator/build.gradle.kts index 94a68f8a9..c39ff0ab5 100644 --- a/authenticator/build.gradle.kts +++ b/authenticator/build.gradle.kts @@ -1,4 +1,6 @@ +import com.android.build.gradle.internal.api.BaseVariantOutputImpl import com.google.protobuf.gradle.proto +import dagger.hilt.android.plugin.util.capitalize import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { @@ -54,6 +56,7 @@ android { buildTypes { debug { + applicationIdSuffix = ".dev" manifestPlaceholders["targetBitwardenAppId"] = "com.x8bit.bitwarden.dev" buildConfigField( type = "com.bitwarden.authenticatorbridge.manager.model.AuthenticatorBridgeConnectionType", @@ -81,6 +84,32 @@ android { buildConfigField(type = "boolean", name = "HAS_DEBUG_MENU", value = "false") } } + applicationVariants.all { + val bundlesDir = "${layout.buildDirectory.get()}/outputs/bundle" + outputs + .mapNotNull { it as? BaseVariantOutputImpl } + .forEach { output -> + // Set the APK output filename. + output.outputFileName = "$applicationId.apk" + + val variantName = name + val renameTaskName = "rename${variantName.capitalize()}AabFiles" + tasks.register(renameTaskName) { + group = "build" + description = "Renames the bundle files for $variantName variant" + doLast { + renameFile( + "$bundlesDir/$variantName/$namespace-${buildType.name}.aab", + "$applicationId.aab", + ) + } + } + // Force renaming task to execute after the variant is built. + tasks + .getByName("bundle${variantName.capitalize()}") + .finalizedBy(renameTaskName) + } + } compileOptions { sourceCompatibility(libs.versions.jvmTarget.get()) targetCompatibility(libs.versions.jvmTarget.get()) @@ -285,3 +314,18 @@ tasks { dependsOn("check") } } + +private fun renameFile(path: String, newName: String) { + val originalFile = File(path) + if (!originalFile.exists()) { + println("File $originalFile does not exist!") + return + } + + val newFile = File(originalFile.parentFile, newName) + if (originalFile.renameTo(newFile)) { + println("Renamed $originalFile to $newFile") + } else { + throw RuntimeException("Failed to rename $originalFile to $newFile") + } +} diff --git a/authenticator/src/debug/google-services.json b/authenticator/src/debug/google-services.json new file mode 100644 index 000000000..cf2a9a8af --- /dev/null +++ b/authenticator/src/debug/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "867301491091", + "project_id": "bitwarden-authenticator", + "storage_bucket": "bitwarden-authenticator.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:867301491091:android:3ee369dedcd20f6551e866", + "android_client_info": { + "package_name": "com.bitwarden.authenticator.dev" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDDXnnBuWzuh8rlihiMWRPif_sqkGk3fxw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 630d397cb..36dfae5ae 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -123,7 +123,7 @@ platform :android do firebase_app_distribution( app: "1:867301491091:android:50b626dba42a361651e866", android_artifact_type: "AAB", - android_artifact_path: "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator-release.aab", + android_artifact_path: "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator.aab", service_credentials_file: options[:serviceCredentialsFile], groups: "internal-prod-group, livefront", release_notes: release_notes, @@ -136,7 +136,7 @@ platform :android do package_name: "com.bitwarden.authenticator", json_key: options[:serviceCredentialsFile], track: "internal", - aab: "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator-release.aab", + aab: "authenticator/build/outputs/bundle/release/com.bitwarden.authenticator.aab", mapping: "authenticator/build/outputs/mapping/release/mapping.txt", ) end