Skip to content

Commit

Permalink
move global app version flags to sub commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Edney committed Jun 29, 2023
1 parent 5609480 commit 4e7931a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
15 changes: 6 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ func main() {
Port int `help:"Port number for the upload server" default:"443"`
ApiKey string `help:"(required) Bugsnag integration API key for this application"`
FailOnUploadError bool `help:"Stops the upload when a mapping file fails to upload to Bugsnag successfully" default:"false"`
AppVersion string `help:"The version of the application."`
AppVersionCode string `help:"The version code for the application (Android only)."`
AppBundleVersion string `help:"The bundle version for the application (iOS only)."`
Upload struct {

// shared options
Expand Down Expand Up @@ -159,9 +156,9 @@ func main() {
}

err := upload.Dart(commands.Upload.DartSymbol.Path,
commands.AppVersion,
commands.AppVersionCode,
commands.AppBundleVersion,
commands.Upload.DartSymbol.Version,
commands.Upload.DartSymbol.VersionCode,
commands.Upload.DartSymbol.BundleVersion,
commands.Upload.DartSymbol.IosAppPath,
endpoint,
commands.Upload.Timeout,
Expand Down Expand Up @@ -224,9 +221,9 @@ func main() {
commands.CreateBuild.Provider,
commands.CreateBuild.Repository,
commands.CreateBuild.Revision,
commands.AppVersion,
commands.AppVersionCode,
commands.AppBundleVersion,
commands.CreateBuild.Version,
commands.CreateBuild.VersionCode,
commands.CreateBuild.BundleVersion,
commands.CreateBuild.Metadata,
commands.CreateBuild.Path,
endpoint)
Expand Down
27 changes: 15 additions & 12 deletions pkg/build/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ import (
)

type CreateBuild struct {
BuilderName string `help:"The name of the entity that triggered the build. Could be a user, system etc."`
Metadata map[string]string `help:"Additional build information"`
ReleaseStage string `help:"The release stage (eg, production, staging) that is being released (if applicable)."`
Provider string `help:"The name of the source control provider that contains the source code for the build."`
Repository string `help:"The URL of the repository containing the source code being deployed."`
Revision string `help:"The source control SHA-1 hash for the code that has been built (short or long hash)"`
Path utils.UploadPaths `arg:"" name:"path" help:"Path to the project directory" type:"path" default:"."`
BuilderName string `help:"The name of the entity that triggered the build. Could be a user, system etc."`
Metadata map[string]string `help:"Additional build information"`
ReleaseStage string `help:"The release stage (eg, production, staging) that is being released (if applicable)."`
Provider string `help:"The name of the source control provider that contains the source code for the build."`
Repository string `help:"The URL of the repository containing the source code being deployed."`
Revision string `help:"The source control SHA-1 hash for the code that has been built (short or long hash)"`
Path utils.UploadPaths `arg:"" name:"path" help:"Path to the project directory" type:"path" default:"."`
Version string `help:"The version of the application."`
VersionCode string `help:"The version code for the application (Android only)."`
BundleVersion string `help:"The bundle version for the application (iOS only)."`
}

type Payload struct {
Expand All @@ -40,8 +43,8 @@ type SourceControl struct {
Revision string `json:"revision,omitempty"`
}

func ProcessBuildRequest(apiKey string, builderName string, releaseStage string, provider string, repository string, revision string, appVersion string, appVersionCode string, appBundleVersion string, metadata map[string]string, paths []string, endpoint string) error {
if appVersion == "" {
func ProcessBuildRequest(apiKey string, builderName string, releaseStage string, provider string, repository string, revision string, version string, versionCode string, bundleVersion string, metadata map[string]string, paths []string, endpoint string) error {
if version == "" {
log.Error("Missing app version, please provide this via the command line options", 1)
}

Expand All @@ -63,9 +66,9 @@ func ProcessBuildRequest(apiKey string, builderName string, releaseStage string,
Revision: repoInfo["revision"],
},
Metadata: metadata,
AppVersion: appVersion,
AppVersionCode: appVersionCode,
AppBundleVersion: appBundleVersion,
AppVersion: version,
AppVersionCode: versionCode,
AppBundleVersion: bundleVersion,
}

buildPayload, err := json.Marshal(payload)
Expand Down
13 changes: 8 additions & 5 deletions pkg/upload/dart.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ import (
)

type DartSymbol struct {
Path utils.UploadPaths `arg:"" name:"path" help:"(required) Path to directory or file to upload" type:"path"`
IosAppPath string `help:"(optional) the path to the built iOS app."`
Path utils.UploadPaths `arg:"" name:"path" help:"(required) Path to directory or file to upload" type:"path"`
IosAppPath string `help:"(optional) the path to the built iOS app."`
Version string `help:"The version of the application."`
VersionCode string `help:"The version code for the application (Android only)."`
BundleVersion string `help:"The bundle version for the application (iOS only)."`
}

func Dart(paths []string, appVersion string, appVersionCode string, appBundleVersion string, iosAppPath string, endpoint string, timeout int, retries int, overwrite bool, apiKey string, failOnUploadError bool) error {
func Dart(paths []string, version string, versionCode string, bundleVersion string, iosAppPath string, endpoint string, timeout int, retries int, overwrite bool, apiKey string, failOnUploadError bool) error {
log.Info("Building file list from path")

fileList, err := utils.BuildFileList(paths)
Expand Down Expand Up @@ -50,7 +53,7 @@ func Dart(paths []string, appVersion string, appVersionCode string, appBundleVer
}

// Build Upload options
uploadOptions := utils.BuildDartUploadOptions(apiKey, buildId, "android", overwrite, appVersion, appVersionCode)
uploadOptions := utils.BuildDartUploadOptions(apiKey, buildId, "android", overwrite, version, versionCode)

fileFieldData := make(map[string]string)
fileFieldData["symbolFile"] = file
Expand Down Expand Up @@ -95,7 +98,7 @@ func Dart(paths []string, appVersion string, appVersionCode string, appBundleVer
}

// Build Upload options
uploadOptions := utils.BuildDartUploadOptions(apiKey, buildId, "ios", overwrite, appVersion, appBundleVersion)
uploadOptions := utils.BuildDartUploadOptions(apiKey, buildId, "ios", overwrite, version, bundleVersion)

fileFieldData := make(map[string]string)
fileFieldData["symbolFile"] = file
Expand Down

0 comments on commit 4e7931a

Please sign in to comment.