private async UniTask UploadArtifact(AndroidPublisherService androidPublisherService, IAndroidDistributionSettings configs, AppEdit appEdit) { var isAppBundle = configs.IsAppBundle; var uploader = isAppBundle ? new AndroidAppBundlerUploader() : new AndroidApkUploader() as IAndroidArtifactUploader; Debug.Log($"{nameof(PlayStorePublisher)} : Upload to store With {uploader.GetType().Name}"); // Upload new apk to developer console var upload = uploader.Upload(configs, androidPublisherService, appEdit); upload.UploadAsync(); var uploadProgress = upload.GetProgress(); while (uploadProgress == null || (uploadProgress.Status != UploadStatus.Completed && uploadProgress.Status != UploadStatus.Failed)) { uploadProgress = upload.GetProgress(); if (uploadProgress != null) { OnUploadProgressChanged(uploadProgress); } Thread.Sleep(UploadAwaitTimeout); } switch (uploadProgress) { case { Status: UploadStatus.Completed } :
public static void UpdateTrackInformation(this Track track, int?versionCode, IAndroidDistributionSettings configs) { var apkVersionCodes = new List <long?> { versionCode }; var releaseNotes = new List <LocalizedText>(); if (!string.IsNullOrEmpty(configs.RecentChangesLang) && !string.IsNullOrEmpty(configs.RecentChangesLang)) { releaseNotes.Add(new LocalizedText() { Language = configs.RecentChangesLang, Text = configs.RecentChanges, }); } var release = new TrackRelease { Name = configs.ReleaseName, ReleaseNotes = releaseNotes, Status = configs.TrackStatus, VersionCodes = apkVersionCodes, }; if (configs.TrackStatus != CompletedStatus) { release.UserFraction = configs.UserFraction; } track.Releases.Add(release); Debug.Log("Update Track information (Without Commit)."); }
public async void Publish(IAndroidDistributionSettings configs) { _uploadSize = 0; _progressData = new ProgressData(); _progress.Value = _progressData; if (configs == null) { throw new Exception("Cannot load a valid BundleConfig"); } var uploadedFile = configs.ArtifactPath; if (!File.Exists(uploadedFile)) { Debug.LogError($"{nameof(PlayStorePublisher)} : File not found"); return; } var fileSource = new FileInfo(uploadedFile); _uploadSize = fileSource.Length; _progressData.Title = uploadedFile; //Create publisherService using (var androidPublisherService = CreateGoogleConsoleAPIService(configs)) { var appEdit = CreateAppEdit(androidPublisherService, configs); await UploadArtifact(androidPublisherService, configs, appEdit); } }
public static Track LoadTrackBranch( this AndroidPublisherService androidPublisherService, IAndroidDistributionSettings configs, AppEdit edit) { var track = androidPublisherService.Edits.Tracks.Get(configs.PackageName, edit.Id, configs.TrackBranch) .Execute(); Debug.Log($"Load TrackBranch:{track.TrackValue}"); return(track); }
private AppEdit CreateAppEdit( AndroidPublisherService androidPublisherService, IAndroidDistributionSettings configs) { var edit = androidPublisherService.Edits .Insert(null /** no content */, configs.PackageName) .Execute(); Debug.Log("Created edit with id: " + edit.Id + " (valid for " + edit.ExpiryTimeSeconds + " seconds)"); return(edit); }
public ResumableUpload Upload( IAndroidDistributionSettings configs, AndroidPublisherService androidPublisherService, AppEdit edit) { Debug.Log("Upload started for : " + Path.GetFileName(configs.ArtifactPath)); var upload = androidPublisherService.Edits.Apks.Upload( configs.PackageName, edit.Id, new FileStream(configs.ArtifactPath, FileMode.Open), "application/vnd.android.package-archive" ); upload.ResponseReceived += x => OnUploadResponce(x, androidPublisherService, configs, edit); return(upload); }
private void UploadObbFiles(AndroidPublisherService service, AppEdit edit, Apk apk, IAndroidDistributionSettings configs, string[] obbs) { foreach (var obbPath in obbs) { var upload = service.Edits.Expansionfiles.Upload( configs.PackageName, edit.Id, apk.VersionCode.Value, EditsResource.ExpansionfilesResource.UploadMediaUpload.ExpansionFileTypeEnum.Main, new FileStream(obbPath, FileMode.Open), "application/octet-stream" ); Debug.Log($"Starting Uploading Obb:{obbPath}"); upload.ResponseReceived += response => { if (response == null) { throw new Exception("Failed Upload " + obbPath); } else { Debug.Log("Success Upload " + obbPath); } }; var result = upload.Upload(); if (result.Exception != null) { throw new Exception("Error: " + result.Exception.Message); } if (result.Status != UploadStatus.Completed) { throw new Exception("Obb not uploaded"); } Debug.Log($"Finish Uploading Obb:{obbPath}"); } }
private bool CheckIfNeedProcessObb(IAndroidDistributionSettings configs, out string[] f) { var apkFolder = Directory.GetParent(configs.ArtifactPath); Debug.Log($"Trying find obb on Path: {apkFolder}"); var boolNeedProcessObb = false; var tempList = new List <string>(); var files = apkFolder.GetFiles(); foreach (var fileInfo in files) { if (fileInfo.Extension == ".obb") { boolNeedProcessObb = true; tempList.Add(fileInfo.FullName); } } f = tempList.ToArray(); Debug.Log($"Need Upload Obb:{boolNeedProcessObb}"); return(boolNeedProcessObb); }
public void OnUploadResponce(Bundle bundle, AndroidPublisherService androidPublisherService, IAndroidDistributionSettings configs, AppEdit edit) { if (bundle == null) { return; } var track = androidPublisherService.LoadTrackBranch(configs, edit); track.UpdateTrackInformation(bundle.VersionCode, configs); var updatedTrack = androidPublisherService.Edits.Tracks .Update(track, configs.PackageName, edit.Id, track.TrackValue).Execute(); Debug.Log("Track " + updatedTrack.TrackValue + " has been updated."); }
private void OnUploadResponce(Apk apk, AndroidPublisherService androidPublisherService, IAndroidDistributionSettings configs, AppEdit edit) { if (apk == null) { return; } var track = androidPublisherService.LoadTrackBranch(configs, edit); track.UpdateTrackInformation(apk.VersionCode, configs); //Verify if exist any obb var needUploadExtensionsFiles = CheckIfNeedProcessObb(configs, out string[] obbs); if (needUploadExtensionsFiles) { UploadObbFiles(androidPublisherService, edit, apk, configs, obbs); } var updatedTrack = androidPublisherService.Edits.Tracks .Update(track, configs.PackageName, edit.Id, track.TrackValue).Execute(); Debug.Log("Track " + updatedTrack.TrackValue + " has been updated."); }
public void Publish(IAndroidDistributionSettings uploadSettings) { var androidPublisher = new PlayStorePublisher(); androidPublisher.Publish(uploadSettings); }