diff --git a/e2e/bitrise.yml b/e2e/bitrise.yml index 3362327..e13634c 100644 --- a/e2e/bitrise.yml +++ b/e2e/bitrise.yml @@ -66,6 +66,7 @@ workflows: - build_version: 9994 - build_version_offset: 5 - build_short_version_string: 9.99.9 + - verbose: "true" - script: title: Build app inputs: diff --git a/step.yml b/step.yml index 04d80a8..5006f68 100644 --- a/step.yml +++ b/step.yml @@ -112,6 +112,16 @@ inputs: If it is empty then the step will not modify the existing value. +- verbose: "false" + opts: + category: Debug + title: Enable verbose logging + summary: Enable logging additional information for debugging. + is_required: true + value_options: + - "true" + - "false" + outputs: - XCODE_BUNDLE_VERSION: opts: diff --git a/step/models.go b/step/models.go index eb1cbc8..3e5c3d8 100644 --- a/step/models.go +++ b/step/models.go @@ -8,6 +8,7 @@ type Input struct { BuildVersion int64 `env:"build_version,required"` BuildVersionOffset int64 `env:"build_version_offset"` BuildShortVersionString string `env:"build_short_version_string"` + Verbose bool `env:"verbose,required"` } type Config struct { diff --git a/step/step.go b/step/step.go index 926ea73..a57a690 100644 --- a/step/step.go +++ b/step/step.go @@ -47,11 +47,20 @@ func (u Updater) ProcessConfig() (Config, error) { return Config{}, fmt.Errorf("build version offset cannot be a negative value (%d)", input.BuildVersionOffset) } + u.logger.EnableDebugLog(input.Verbose) + stepconf.Print(input) u.logger.Println() - // golangci told me that I should do this instead of creating a Config struct. - return Config(input), nil + return Config{ + ProjectPath: input.ProjectPath, + Scheme: input.Scheme, + Target: input.Target, + Configuration: input.Configuration, + BuildVersion: input.BuildVersion, + BuildVersionOffset: input.BuildVersionOffset, + BuildShortVersionString: input.BuildShortVersionString, + }, nil } func (u Updater) Run(config Config) (Result, error) { @@ -70,7 +79,7 @@ func (u Updater) Run(config Config) (Result, error) { if generated { u.logger.Printf("The version numbers are stored in the project file.") - err := updateVersionNumbersInProject(helper, config.Target, config.Configuration, buildVersion, config.BuildShortVersionString) + err := u.updateVersionNumbersInProject(helper, config.Target, config.Configuration, buildVersion, config.BuildShortVersionString) if err != nil { return Result{}, err } @@ -103,7 +112,7 @@ func generatesInfoPlist(helper *projectmanager.ProjectHelper, targetName, config return generatesInfoPlist, err } -func updateVersionNumbersInProject(helper *projectmanager.ProjectHelper, targetName, configuration string, bundleVersion int64, shortVersion string) error { +func (u Updater) updateVersionNumbersInProject(helper *projectmanager.ProjectHelper, targetName, configuration string, bundleVersion int64, shortVersion string) error { if targetName == "" { targetName = helper.MainTarget.Name } @@ -118,10 +127,18 @@ func updateVersionNumbersInProject(helper *projectmanager.ProjectHelper, targetN continue } + u.logger.Printf("Updating build settings for the %s target", target.Name) + + oldProjectVersion := buildConfig.BuildSettings["CURRENT_PROJECT_VERSION"] buildConfig.BuildSettings["CURRENT_PROJECT_VERSION"] = bundleVersion + u.logger.Debugf("CURRENT_PROJECT_VERSION %s -> %d", oldProjectVersion, bundleVersion) + if shortVersion != "" { + oldMarketingVersion := buildConfig.BuildSettings["MARKETING_VERSION"] buildConfig.BuildSettings["MARKETING_VERSION"] = shortVersion + + u.logger.Debugf("MARKETING_VERSION %s -> %s", oldMarketingVersion, shortVersion) } } } @@ -168,11 +185,20 @@ func (u Updater) updateVersionNumbersInInfoPlist(helper *projectmanager.ProjectH infoPlistPath = filepath.Join(filepath.Dir(helper.XcProj.Path), infoPlistPath) } + u.logger.Printf("Updating Info.plist at %s", infoPlistPath) + infoPlist, format, _ := xcodeproj.ReadPlistFile(infoPlistPath) - infoPlist["CFBundleVersion"] = strconv.FormatInt(bundleVersion, 10) + oldVersion := infoPlist["CFBundleVersion"] + newVersion := strconv.FormatInt(bundleVersion, 10) + infoPlist["CFBundleVersion"] = newVersion + + u.logger.Debugf("CFBundleVersion %s -> %s", oldVersion, newVersion) if shortVersion != "" { + oldVersionString := infoPlist["CFBundleShortVersionString"] infoPlist["CFBundleShortVersionString"] = shortVersion + + u.logger.Debugf("CFBundleShortVersionString %s -> %s", oldVersionString, shortVersion) } err = xcodeproj.WritePlistFile(infoPlistPath, infoPlist, format)