Skip to content

Commit

Permalink
Introduces new --set-beta-group and --set-beta-tester flags toselecti…
Browse files Browse the repository at this point in the history
…vely override these configurations for an individual build.These flags can be used in scenarios where you want to release abeta build to specific groups and/or a pool of testers beyond whatyou would normally release betas to. This could be useful on adistributed development team where different QA groups and productowners want to receive beta builds independently of a company-wideor official TestFlight release for public beta consumption.Fixes #18
  • Loading branch information
aaronsky committed Sep 15, 2020
1 parent 6b8bbdf commit e14a80a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 29 deletions.
51 changes: 38 additions & 13 deletions cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/apex/log"
"github.com/cidertool/cider/internal/middleware"
"github.com/cidertool/cider/internal/pipeline"
"github.com/cidertool/cider/pkg/config"
"github.com/cidertool/cider/pkg/context"
"github.com/fatih/color"
"github.com/spf13/cobra"
Expand All @@ -18,18 +19,20 @@ type releaseCmd struct {
}

type releaseOpts struct {
config string
appsToRelease []string
publishMode context.PublishMode
releaseAllApps bool
skipGit bool
skipUpdatePricing bool
skipUpdateMetadata bool
skipSubmit bool
timeout time.Duration
versionOverride string
buildOverride string
currentDirectory string
config string
appsToRelease []string
publishMode context.PublishMode
releaseAllApps bool
skipGit bool
skipUpdatePricing bool
skipUpdateMetadata bool
skipSubmit bool
timeout time.Duration
versionOverride string
buildOverride string
betaGroupsOverride []string
betaTestersOverride []string
currentDirectory string
}

func newReleaseCmd() *releaseCmd {
Expand Down Expand Up @@ -71,7 +74,9 @@ func newReleaseCmd() *releaseCmd {
cmd.Flags().BoolVar(&root.opts.skipUpdateMetadata, "skip-update-metadata", false, "Skips updating metadata")
cmd.Flags().BoolVar(&root.opts.skipSubmit, "skip-submit", false, "Skips submitting for review")
cmd.Flags().StringVarP(&root.opts.versionOverride, "set-version", "V", "", "Version override to use instead of Git tags")
cmd.Flags().StringVarP(&root.opts.buildOverride, "set-build", "B", "", `Build override to use instead of "latest".`)
cmd.Flags().StringVarP(&root.opts.buildOverride, "set-build", "B", "", `Build override to use instead of "latest"`)
cmd.Flags().StringArrayVar(&root.opts.betaGroupsOverride, "set-beta-group", []string{}, `Beta group names override to use instead of the YAML configuration`)
cmd.Flags().StringArrayVar(&root.opts.betaTestersOverride, "set-beta-tester", []string{}, `Beta tester emails override to use instead of the YAML configuration`)
cmd.Flags().DurationVar(&root.opts.timeout, "timeout", 30*time.Minute, "Timeout to the entire release process")

root.cmd = cmd
Expand Down Expand Up @@ -120,6 +125,26 @@ func setupReleaseContext(ctx *context.Context, options releaseOpts, forceAllSkip
ctx.SkipSubmit = options.skipSubmit || forceAllSkips
ctx.Version = options.versionOverride
ctx.Build = options.buildOverride

if len(options.betaGroupsOverride) > 0 || len(options.betaTestersOverride) > 0 {
var betaTesters = make([]config.BetaTester, len(options.betaTestersOverride))

for i, email := range options.betaTestersOverride {
betaTesters[i] = config.BetaTester{Email: email}
}

for appName, app := range ctx.Config.Apps {
if len(options.betaGroupsOverride) > 0 {
app.Testflight.BetaGroups = options.betaGroupsOverride
}
if len(betaTesters) > 0 {
app.Testflight.BetaTesters = betaTesters
}
ctx.Config.Apps[appName] = app
}
}

ctx.CurrentDirectory = options.currentDirectory

return ctx
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Masterminds/semver/v3 v3.1.0
github.com/alessio/shellescape v1.2.2
github.com/apex/log v1.9.0
github.com/cidertool/asc-go v0.3.4
github.com/cidertool/asc-go v0.3.5
github.com/fatih/color v1.9.0
github.com/hashicorp/go-multierror v1.1.0
github.com/manifoldco/promptui v0.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cidertool/asc-go v0.3.4 h1:912W030XcmxuuwQqZcm7rUtniRZO5mCZZWBRLrZCzts=
github.com/cidertool/asc-go v0.3.4/go.mod h1:KwOKlc2MwulaVFejJJSJkVKuIWX5HdedcbdX/QzeeFE=
github.com/cidertool/asc-go v0.3.5 h1:FGkuh6K0q3DovUYqoYcQz3LkKpUoONbgd7SQH+LeR/4=
github.com/cidertool/asc-go v0.3.5/go.mod h1:KwOKlc2MwulaVFejJJSJkVKuIWX5HdedcbdX/QzeeFE=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down
15 changes: 15 additions & 0 deletions internal/client/testflight.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"github.com/apex/log"
"github.com/cidertool/asc-go/asc"
"github.com/cidertool/cider/pkg/config"
"github.com/cidertool/cider/pkg/context"
Expand Down Expand Up @@ -100,6 +101,7 @@ func (c *ascClient) UpdateBetaLicenseAgreement(ctx *context.Context, app *asc.Ap

func (c *ascClient) AssignBetaGroups(ctx *context.Context, build *asc.Build, groups []string) error {
if len(groups) == 0 {
log.Debug("no groups provided as input to add")
return nil
}
groupsResp, _, err := c.client.TestFlight.ListBetaGroups(ctx, &asc.ListBetaGroupsQuery{
Expand All @@ -108,17 +110,22 @@ func (c *ascClient) AssignBetaGroups(ctx *context.Context, build *asc.Build, gro
if err != nil {
return err
}
if len(groupsResp.Data) == 0 {
log.WithField("groups", groups).Warn("no matching groups found")
}
for _, group := range groupsResp.Data {
_, err := c.client.TestFlight.AddBuildsToBetaGroup(ctx, group.ID, []string{build.ID})
if err != nil {
return err
}
}
log.Infof("assigned %d beta group(s)", len(groupsResp.Data))
return nil
}

func (c *ascClient) AssignBetaTesters(ctx *context.Context, build *asc.Build, testers []config.BetaTester) error {
if len(testers) == 0 {
log.Debug("no testers provided as input to add")
return nil
}
emailFilters := make([]string, 0)
Expand All @@ -144,12 +151,20 @@ func (c *ascClient) AssignBetaTesters(ctx *context.Context, build *asc.Build, te
if err != nil {
return err
}
if len(testersResp.Data) == 0 {
log.WithFields(log.Fields{
"emails": emailFilters,
"firstNames": firstNameFilters,
"lastNames": lastNameFilters,
}).Warn("no matching testers found")
}
for _, tester := range testersResp.Data {
_, err := c.client.TestFlight.AssignSingleBetaTesterToBuilds(ctx, tester.ID, []string{build.ID})
if err != nil {
return err
}
}
log.Infof("assigned %d beta tester(s)", len(testersResp.Data))
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions internal/pipe/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,32 @@ func updateVersionDetails(ctx *context.Context, config config.App, client client
if err != nil {
return err
}
log.Debug("updating app details")
log.Info("updating app details")
if err := client.UpdateApp(ctx, app, appInfo, config); err != nil {
return err
}
log.Debugf("updating %d app localizations", len(config.Localizations))
log.Infof("updating %d app localizations", len(config.Localizations))
if err := client.UpdateAppLocalizations(ctx, app, appInfo, config.Localizations); err != nil {
return err
}
log.Debugf("updating %d app store version localizations", len(config.Versions.Localizations))
log.Infof("updating %d app store version localizations", len(config.Versions.Localizations))
if err := client.UpdateVersionLocalizations(ctx, version, config.Versions.Localizations); err != nil {
return err
}
if config.Versions.IDFADeclaration != nil {
log.Debug("updating IDFA declaration")
log.Info("updating IDFA declaration")
if err := client.UpdateIDFADeclaration(ctx, version, *config.Versions.IDFADeclaration); err != nil {
return err
}
}
if config.Versions.RoutingCoverage != nil {
log.Debug("uploading routing coverage asset")
log.Info("uploading routing coverage asset")
if err := client.UploadRoutingCoverage(ctx, version, *config.Versions.RoutingCoverage); err != nil {
return err
}
}
if config.Versions.ReviewDetails != nil {
log.Debug("updating review details")
log.Info("updating review details")
if err := client.UpdateReviewDetails(ctx, version, *config.Versions.ReviewDetails); err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions internal/pipe/testflight/testflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,32 @@ func doRelease(ctx *context.Context, config config.App, client client.Client) er
}

func updateBetaDetails(ctx *context.Context, config config.App, client client.Client, app *asc.App, build *asc.Build) error {
log.Debugf("updating %d beta app localizations", len(config.Testflight.Localizations))
log.Infof("updating %d beta app localizations", len(config.Testflight.Localizations))
if err := client.UpdateBetaAppLocalizations(ctx, app, config.Testflight.Localizations); err != nil {
return err
}
log.Debug("updating beta build details")
log.Info("updating beta build details")
if err := client.UpdateBetaBuildDetails(ctx, build, config.Testflight); err != nil {
return err
}
log.Debugf("updating %d beta build localizations", len(config.Testflight.Localizations))
log.Infof("updating %d beta build localizations", len(config.Testflight.Localizations))
if err := client.UpdateBetaBuildLocalizations(ctx, build, config.Testflight.Localizations); err != nil {
return err
}
log.Debug("updating beta license agreement")
log.Info("updating beta license agreement")
if err := client.UpdateBetaLicenseAgreement(ctx, app, config.Testflight); err != nil {
return err
}
log.Debug("updating build beta groups")
log.Info("updating build beta groups")
if err := client.AssignBetaGroups(ctx, build, config.Testflight.BetaGroups); err != nil {
return err
}
log.Debug("updating build beta testers")
log.Info("updating build beta testers")
if err := client.AssignBetaTesters(ctx, build, config.Testflight.BetaTesters); err != nil {
return err
}
if config.Testflight.ReviewDetails != nil {
log.Debug("updating beta review details")
log.Info("updating beta review details")
if err := client.UpdateBetaReviewDetails(ctx, app, *config.Testflight.ReviewDetails); err != nil {
return err
}
Expand Down

0 comments on commit e14a80a

Please sign in to comment.