diff --git a/config.go b/config.go index 1250ff92..a25d039b 100755 --- a/config.go +++ b/config.go @@ -13,18 +13,19 @@ import ( // Configs stores the step's inputs type Configs struct { - JSONKeyPath stepconf.Secret `env:"service_account_json_key_path,required"` - PackageName string `env:"package_name,required"` - AppPath string `env:"app_path,required"` - ExpansionfilePath string `env:"expansionfile_path"` - Track string `env:"track,required"` - UserFraction float64 `env:"user_fraction,range]0.0..1.0["` - UpdatePriority int `env:"update_priority,range[0..5]"` - WhatsnewsDir string `env:"whatsnews_dir"` - MappingFile string `env:"mapping_file"` - ReleaseName string `env:"release_name"` - Status string `env:"status"` - RetryWithoutSendingToReview bool `env:"retry_without_sending_to_review,opt[true,false]"` + JSONKeyPath stepconf.Secret `env:"service_account_json_key_path,required"` + PackageName string `env:"package_name,required"` + AppPath string `env:"app_path,required"` + ExpansionfilePath string `env:"expansionfile_path"` + Track string `env:"track,required"` + UserFraction float64 `env:"user_fraction,range]0.0..1.0["` + UpdatePriority int `env:"update_priority,range[0..5]"` + WhatsnewsDir string `env:"whatsnews_dir"` + MappingFile string `env:"mapping_file"` + ReleaseName string `env:"release_name"` + Status string `env:"status"` + RetryWithoutSendingToReview bool `env:"retry_without_sending_to_review,opt[true,false]"` + AckBundleInstallationWarning bool `env:"ack_bundle_installation_warning,opt[true,false]"` } // validate validates the Configs. diff --git a/main.go b/main.go index 819ac154..d44be834 100755 --- a/main.go +++ b/main.go @@ -44,7 +44,7 @@ func uploadApplications(configs Configs, service *androidpublisher.Service, appE } if strings.ToLower(filepath.Ext(appPath)) == ".aab" { - bundle, err := uploadAppBundle(service, configs.PackageName, appEdit.Id, appFile) + bundle, err := uploadAppBundle(service, configs.PackageName, appEdit.Id, appFile, configs.AckBundleInstallationWarning) if err != nil { return nil, err } @@ -196,7 +196,7 @@ func executeEdit(service *androidpublisher.Service, configs Configs, changesNotS log.Infof("Upload apks or app bundles") versionCodes, err := uploadApplications(configs, service, appEdit) if err != nil { - return fmt.Sprintf("Failed to upload APKs: %v", err) + return fmt.Sprintf("Failed to upload application(s): %v", err) } log.Donef("Applications uploaded") diff --git a/publish.go b/publish.go index 8653a314..4beacaba 100755 --- a/publish.go +++ b/publish.go @@ -20,6 +20,9 @@ const ( releaseStatusHalted = "halted" ) +const bundleInstallationWarning = "Error 403: The installation of the app bundle may be too large " + + "and trigger user warning on some devices, and this needs to be explicitly acknowledged in the request." + // uploadExpansionFiles uploads the expansion files for given applications, like .obb files. func uploadExpansionFiles(service *androidpublisher.Service, expFileEntry string, packageName string, appEditID string, versionCode int64) error { cleanExpFileConfigEntry := strings.TrimSpace(expFileEntry) @@ -92,16 +95,21 @@ func uploadMappingFile(service *androidpublisher.Service, configs Configs, appEd } // uploadAppBundle uploads aab files to Google Play. Returns the uploaded bundle itself or an error. -func uploadAppBundle(service *androidpublisher.Service, packageName string, appEditID string, appFile *os.File) (*androidpublisher.Bundle, error) { +func uploadAppBundle(service *androidpublisher.Service, packageName string, appEditID string, appFile *os.File, ackBundleInstallationWarning bool) (*androidpublisher.Bundle, error) { log.Debugf("Uploading file %v with package name '%v', AppEditId '%v", appFile, packageName, appEditID) editsBundlesService := androidpublisher.NewEditsBundlesService(service) editsBundlesUploadCall := editsBundlesService.Upload(packageName, appEditID) editsBundlesUploadCall.Media(appFile, googleapi.ContentType("application/octet-stream")) + editsBundlesUploadCall.AckBundleInstallationWarning(ackBundleInstallationWarning) bundle, err := editsBundlesUploadCall.Do() if err != nil { - return &androidpublisher.Bundle{}, fmt.Errorf("failed to upload app bundle, error: %s", err) + msg := fmt.Sprintf("failed to upload app bundle, error: %s", err) + if strings.Contains(err.Error(), bundleInstallationWarning) { + msg = fmt.Sprintf("%s\nTo acknowledge this warning, set the Acknowledge Bundle Installation Warning (ack_bundle_installation_warning) input to true.", msg) + } + return nil, fmt.Errorf(msg) } log.Infof("Uploaded app bundle version: %d", bundle.VersionCode) return bundle, nil @@ -117,7 +125,7 @@ func uploadAppApk(service *androidpublisher.Service, packageName string, appEdit apk, err := editsApksUploadCall.Do() if err != nil { - return &androidpublisher.Apk{}, fmt.Errorf("failed to upload apk, error: %s", err) + return nil, fmt.Errorf("failed to upload apk, error: %s", err) } log.Infof("Uploaded apk version: %d", apk.VersionCode) return apk, nil diff --git a/step.yml b/step.yml index 2fc177ef..b2068bc6 100755 --- a/step.yml +++ b/step.yml @@ -173,3 +173,14 @@ inputs: value_options: - "true" - "false" + +- ack_bundle_installation_warning: "false" + opts: + title: Acknowledge Bundle Installation Warning + description: |- + Must be set to `true` if the App Bundle installation may trigger a warning on user devices + (for example, if installation size may be over a threshold, typically 100 MB). + is_required: true + value_options: + - "true" + - "false"