Skip to content

Commit

Permalink
fix: change BuildVersion to int64 allowing larger build numbers (#37)
Browse files Browse the repository at this point in the history
* fix: change BuildVersion to int64 allowing larger build numbers

* fix: convert buildnumber from int64 when writing CFBundleVersion value

---------

Co-authored-by: Asser Hakala <[email protected]>
Co-authored-by: Szabolcs Toth <[email protected]>
  • Loading branch information
3 people authored Feb 27, 2024
1 parent 1f2e770 commit f48226b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions step/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ type Input struct {
Scheme string `env:"scheme,required"`
Target string `env:"target"`
Configuration string `env:"configuration"`
BuildVersion int `env:"build_version,required"`
BuildVersionOffset int `env:"build_version_offset"`
BuildVersion int64 `env:"build_version,required"`
BuildVersionOffset int64 `env:"build_version_offset"`
BuildShortVersionString string `env:"build_short_version_string"`
}

Expand All @@ -15,11 +15,11 @@ type Config struct {
Scheme string
Target string
Configuration string
BuildVersion int
BuildVersionOffset int
BuildVersion int64
BuildVersionOffset int64
BuildShortVersionString string
}

type Result struct {
BuildVersion int
BuildVersion int64
}
8 changes: 4 additions & 4 deletions step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (u Updater) Run(config Config) (Result, error) {
}

func (u Updater) Export(result Result) error {
return u.exporter.ExportOutput("XCODE_BUNDLE_VERSION", strconv.Itoa(result.BuildVersion))
return u.exporter.ExportOutput("XCODE_BUNDLE_VERSION", strconv.FormatInt(result.BuildVersion, 10))
}

func generatesInfoPlist(helper *projectmanager.ProjectHelper, targetName, configuration string) (bool, error) {
Expand All @@ -93,7 +93,7 @@ func generatesInfoPlist(helper *projectmanager.ProjectHelper, targetName, config
return generatesInfoPlist, err
}

func updateVersionNumbersInProject(helper *projectmanager.ProjectHelper, targetName, configuration string, bundleVersion int, shortVersion string) error {
func updateVersionNumbersInProject(helper *projectmanager.ProjectHelper, targetName, configuration string, bundleVersion int64, shortVersion string) error {
if targetName == "" {
targetName = helper.MainTarget.Name
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func updateVersionNumbersInProject(helper *projectmanager.ProjectHelper, targetN
return nil
}

func updateVersionNumbersInInfoPlist(helper *projectmanager.ProjectHelper, targetName, configuration string, bundleVersion int, shortVersion string) error {
func updateVersionNumbersInInfoPlist(helper *projectmanager.ProjectHelper, targetName, configuration string, bundleVersion int64, shortVersion string) error {
buildConfig, err := buildConfiguration(helper, targetName, configuration)
if err != nil {
return err
Expand All @@ -138,7 +138,7 @@ func updateVersionNumbersInInfoPlist(helper *projectmanager.ProjectHelper, targe
absoluteInfoPlistPath := filepath.Join(filepath.Dir(helper.XcProj.Path), infoPlistPath)

infoPlist, format, _ := xcodeproj.ReadPlistFile(absoluteInfoPlistPath)
infoPlist["CFBundleVersion"] = strconv.Itoa(bundleVersion)
infoPlist["CFBundleVersion"] = strconv.FormatInt(bundleVersion, 10)

if shortVersion != "" {
infoPlist["CFBundleShortVersionString"] = shortVersion
Expand Down
2 changes: 1 addition & 1 deletion step/step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestExport(t *testing.T) {
result := Result{BuildVersion: 999}

mockFactory := mocks.NewFactory(t)
arguments := []string{"add", "--key", "XCODE_BUNDLE_VERSION", "--value", strconv.Itoa(result.BuildVersion)}
arguments := []string{"add", "--key", "XCODE_BUNDLE_VERSION", "--value", strconv.FormatInt(result.BuildVersion, 10)}
mockFactory.On("Create", "envman", arguments, (*command.Opts)(nil)).Return(testCommand())

inputParser := stepconf.NewInputParser(env.NewRepository())
Expand Down

0 comments on commit f48226b

Please sign in to comment.