Browse Source

release/dist/cli: add option to override out path

Allow builds to be outputted to a specific directory.
By default, or if unset, artifacts are written to PWD/dist.

Updates tailscale/corp#27638

Signed-off-by: Kristoffer Dalby <[email protected]>
Kristoffer Dalby 10 months ago
parent
commit
e84522e3e3
1 changed files with 7 additions and 1 deletions
  1. 7 1
      release/dist/cli/cli.go

+ 7 - 1
release/dist/cli/cli.go

@@ -65,6 +65,7 @@ func CLI(getTargets func() ([]dist.Target, error)) *ffcli.Command {
 					fs.StringVar(&buildArgs.manifest, "manifest", "", "manifest file to write")
 					fs.BoolVar(&buildArgs.verbose, "verbose", false, "verbose logging")
 					fs.StringVar(&buildArgs.webClientRoot, "web-client-root", "", "path to root of web client source to build")
+					fs.StringVar(&buildArgs.outPath, "out", "", "path to write output artifacts (defaults to '$PWD/dist' if not set)")
 					return fs
 				})(),
 				LongHelp: strings.TrimSpace(`
@@ -156,6 +157,7 @@ var buildArgs struct {
 	manifest      string
 	verbose       bool
 	webClientRoot string
+	outPath       string
 }
 
 func runBuild(ctx context.Context, filters []string, targets []dist.Target) error {
@@ -172,7 +174,11 @@ func runBuild(ctx context.Context, filters []string, targets []dist.Target) erro
 	if err != nil {
 		return fmt.Errorf("getting working directory: %w", err)
 	}
-	b, err := dist.NewBuild(wd, filepath.Join(wd, "dist"))
+	outPath := filepath.Join(wd, "dist")
+	if buildArgs.outPath != "" {
+		outPath = buildArgs.outPath
+	}
+	b, err := dist.NewBuild(wd, outPath)
 	if err != nil {
 		return fmt.Errorf("creating build context: %w", err)
 	}