Skip to content

Commit

Permalink
Merge pull request #10 from MisterMX/feat/build-filter-ids
Browse files Browse the repository at this point in the history
feat(build): Add option to build only specific builds
  • Loading branch information
MisterMX authored Mar 28, 2024
2 parents 770edd7 + 49b1146 commit ca211b6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/crossplanereleaser/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"path/filepath"
"slices"

"github.com/pkg/errors"
"github.com/spf13/afero"
Expand All @@ -13,6 +14,8 @@ import (
)

type buildCmd struct {
ID []string `help:"Build only the specified build ids"`

git git.Client
builder build.BuilderBackend
}
Expand All @@ -35,6 +38,10 @@ func (c *buildCmd) Run(fsys afero.Fs) error {

func (c *buildCmd) buildPackages(ctx context.Context, fsys afero.Fs, cfg *v1.Config) error {
for _, b := range cfg.Builds {
if !c.shouldBeBuilt(b) {
continue
}

buildCfg := &build.PackageBuildConfig{
PackageDir: b.Dir,
ExamplesDir: b.Examples,
Expand All @@ -53,6 +60,13 @@ func (c *buildCmd) buildPackages(ctx context.Context, fsys afero.Fs, cfg *v1.Con
return nil
}

func (c *buildCmd) shouldBeBuilt(buildCfg v1.BuildConfig) bool {
if len(c.ID) == 0 {
return true
}
return slices.Contains(c.ID, buildCfg.ID)
}

func getPackageOutputPath(cfg *v1.Config, build *v1.BuildConfig) string {
return filepath.Join(cfg.Dist, build.ID, build.NameTemplate)
}

0 comments on commit ca211b6

Please sign in to comment.