From 5a78cbef0274bfec8ceeff128021f6dbb2214af3 Mon Sep 17 00:00:00 2001 From: Matt Portune <59324545+mportune-bw@users.noreply.github.com> Date: Fri, 17 Apr 2020 17:06:37 -0400 Subject: [PATCH] Tracing bundles (#842) * Output to bundle (play store build only) and enable startup tracing * Update ci build script to recognize bundle (.aab) for Google Play build * Added bundle awareness to `appveyor.yml` and `Program.cs` * Log upload exception * Restore original apk creation alongside the bundle * Remove link skip as AOT doesn't support linking --- appveyor.yml | 3 ++- src/Android/Android.csproj | 7 +++---- src/Android/ci-build-apks.ps1 | 23 ++++++++++++++++++++--- store/google/Publisher/Program.cs | 22 +++++++++++++--------- store/google/Publisher/Publisher.csproj | 2 +- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ee0bd1c37..0710f00ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -98,6 +98,7 @@ build_script: if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } .\src\Android\ci-build-apks.ps1 if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } + Push-AppveyorArtifact .\com.x8bit.bitwarden.aab Push-AppveyorArtifact .\com.x8bit.bitwarden.apk Push-AppveyorArtifact .\com.x8bit.bitwarden-fdroid.apk } @@ -114,7 +115,7 @@ on_success: cd store\google\Publisher\bin\Release\netcoreapp2.0 dotnet Publisher.dll ` $env:APPVEYOR_BUILD_FOLDER\store\google\Publisher\play_creds.json ` - $env:APPVEYOR_BUILD_FOLDER\com.x8bit.bitwarden.apk ` + $env:APPVEYOR_BUILD_FOLDER\com.x8bit.bitwarden.aab ` alpha cd $env:APPVEYOR_BUILD_FOLDER } diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index afe27f7a3..a33c607fb 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -19,7 +19,6 @@ Xamarin.Android.Net.AndroidClientHandler - Xamarin.GooglePlayServices.Base;Xamarin.GooglePlayServices.Basement;Xamarin.GooglePlayServices.Measurement;Xamarin.GooglePlayServices.Gcm;BitwardenAndroid;BitwardenApp;BitwardenCore;Xamarin.Android.Net;Xamarin.Android.Net.OldAndroidSSLSocketFactory;LiteDB;Microsoft.AppCenter.Crashes true @@ -45,7 +44,7 @@ armeabi-v7a;x86;x86_64;arm64-v8a 1G true - Full + true false @@ -61,7 +60,7 @@ 1G false true - Full + true @@ -89,7 +88,7 @@ - + 71.1600.0 diff --git a/src/Android/ci-build-apks.ps1 b/src/Android/ci-build-apks.ps1 index 3c1426e4f..4e23c212f 100644 --- a/src/Android/ci-build-apks.ps1 +++ b/src/Android/ci-build-apks.ps1 @@ -29,16 +29,33 @@ Invoke-Expression "& `"$secureFilePath`" -decrypt $($encKeystorePath) -secret $( Invoke-Expression "& `"$secureFilePath`" -decrypt $($encUploadKeystorePath) -secret $($env:upload_keystore_dec_secret)" echo "########################################" -echo "##### Sign Release Configuration" +echo "##### Sign Google Play Bundle Release Configuration" echo "########################################" msbuild "$($androidPath)" "/t:SignAndroidPackage" "/p:Configuration=Release" "/p:AndroidKeyStore=true" ` "/p:AndroidSigningKeyAlias=upload" "/p:AndroidSigningKeyPass=$($env:upload_keystore_password)" ` "/p:AndroidSigningKeyStore=upload-keystore.jks" "/p:AndroidSigningStorePass=$($env:upload_keystore_password)" ` - "/v:quiet" + "/p:AndroidPackageFormat=aab" "/v:quiet" echo "########################################" -echo "##### Copy Release apk to project root" +echo "##### Copy Google Play Bundle to project root" +echo "########################################" + +$signedAabPath = $($rootPath + "\src\Android\bin\Release\com.x8bit.bitwarden-Signed.aab"); +$signedAabDestPath = $($rootPath + "\com.x8bit.bitwarden.aab"); + +Copy-Item $signedAabPath $signedAabDestPath + +echo "########################################" +echo "##### Sign APK Release Configuration" +echo "########################################" + +msbuild "$($androidPath)" "/t:SignAndroidPackage" "/p:Configuration=Release" "/p:AndroidKeyStore=true" ` + "/p:AndroidSigningKeyAlias=bitwarden" "/p:AndroidSigningKeyPass=$($env:keystore_password)" ` + "/p:AndroidSigningKeyStore=8bit.keystore" "/p:AndroidSigningStorePass=$($env:keystore_password)" "/v:quiet" + +echo "########################################" +echo "##### Copy Release APK to project root" echo "########################################" $signedApkPath = $($rootPath + "\src\Android\bin\Release\com.x8bit.bitwarden-Signed.apk"); diff --git a/store/google/Publisher/Program.cs b/store/google/Publisher/Program.cs index cdb1180ed..b7ab3887c 100644 --- a/store/google/Publisher/Program.cs +++ b/store/google/Publisher/Program.cs @@ -13,7 +13,7 @@ namespace Bit.Publisher { private const string Package = "com.x8bit.bitwarden"; - private static string _apkFilePath; + private static string _aabFilePath; private static string _credsFilePath; private static string _track; @@ -27,7 +27,7 @@ namespace Bit.Publisher try { _credsFilePath = args[0]; - _apkFilePath = args[1]; + _aabFilePath = args[1]; var track = args[2].Substring(0, 1).ToLower(); if (track == "a") @@ -83,31 +83,35 @@ namespace Bit.Publisher Console.WriteLine("Created edit with id {0}.", edit.Id); - Apk apk = null; - using (var stream = new FileStream(_apkFilePath, FileMode.Open)) + Bundle aab = null; + using (var stream = new FileStream(_aabFilePath, FileMode.Open)) { - var uploadMedia = service.Edits.Apks.Upload(Package, edit.Id, stream, - "application/vnd.android.package-archive"); + var uploadMedia = service.Edits.Bundles.Upload(Package, edit.Id, stream, + "application/octet-stream"); var progress = await uploadMedia.UploadAsync(); if (progress.Status == Google.Apis.Upload.UploadStatus.Completed) { - apk = uploadMedia.ResponseBody; + aab = uploadMedia.ResponseBody; } else { + if (progress.Exception != null) + { + Console.WriteLine("Upload exception: {0}", progress.Exception); + } throw new Exception("Upload failed."); } } - Console.WriteLine("Version code {0} has been uploaded.", apk.VersionCode); + Console.WriteLine("Version code {0} has been uploaded.", aab.VersionCode); var trackRequest = service.Edits.Tracks.Update(new Track { TrackValue = _track, Releases = new List { - new TrackRelease { VersionCodes = new List { apk.VersionCode }, Status = "completed" } + new TrackRelease { VersionCodes = new List { aab.VersionCode }, Status = "completed" } } }, Package, edit.Id, _track); diff --git a/store/google/Publisher/Publisher.csproj b/store/google/Publisher/Publisher.csproj index c8e2e6f8d..aeb9e1a78 100644 --- a/store/google/Publisher/Publisher.csproj +++ b/store/google/Publisher/Publisher.csproj @@ -8,7 +8,7 @@ - +