Skip to content

Commit 0373bbc

Browse files
committed
feat: add export-version flag for deploy
1 parent 46aed5f commit 0373bbc

1 file changed

Lines changed: 38 additions & 5 deletions

File tree

cmd/devnet-builder/commands/manage/deploy.go

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var (
3838
deployAccounts int
3939
deployNoInteractive bool
4040
deployStartVersion string
41+
deployExportVersion string // Version for export binary (genesis export), optional
4142
deployImage string
4243
deployFork bool // Fork live network state via snapshot export
4344
deployTestMnemonic bool // Use deterministic test mnemonics for validators
@@ -97,7 +98,11 @@ Examples:
9798
→ Then select "Use local binary" and browse to your binary
9899
99100
# Deploy with fork mode (binary needed for genesis export)
100-
devnet-builder deploy --mode local --fork`,
101+
devnet-builder deploy --mode local --fork
102+
103+
# Deploy with different binary versions for export and start
104+
# (useful when export requires a specific version for state compatibility)
105+
devnet-builder deploy --mode local --start-version v1.2.3 --export-version v1.1.0`,
101106
RunE: runDeploy,
102107
}
103108

@@ -123,6 +128,8 @@ Examples:
123128
"Disable version selection prompts (use --start-version, --image instead)")
124129
cmd.Flags().StringVar(&deployStartVersion, "start-version", "",
125130
"Version for devnet binary (non-interactive mode)")
131+
cmd.Flags().StringVar(&deployExportVersion, "export-version", "",
132+
"Version for genesis export binary (optional, defaults to start-version)")
126133

127134
// Docker image flag
128135
cmd.Flags().StringVar(&deployImage, "image", "",
@@ -213,7 +220,9 @@ func runDeploy(cmd *cobra.Command, args []string) error {
213220
deployAccounts = *effectiveCfg.Accounts
214221
}
215222

216-
// Track version for deployment (unified: same version for export and start)
223+
// Track version for deployment
224+
// startVersion: binary for running nodes
225+
// exportVersion is handled separately via --export-version flag
217226
var startVersion string
218227
var dockerImage string
219228

@@ -222,8 +231,11 @@ func runDeploy(cmd *cobra.Command, args []string) error {
222231
// Skip interactive version selection if --binary flag is provided
223232
isInteractive := !deployNoInteractive && !jsonMode() && deployBinary == ""
224233

225-
// Variable to store custom binary path (set by unified selection or selectBinaryForDeployment)
234+
// Variable to store binary paths
235+
// customBinaryPath: binary for running nodes (start)
236+
// exportBinaryPath: binary for genesis export (may differ if --export-version is set)
226237
var customBinaryPath string
238+
var exportBinaryPath string
227239

228240
// Docker mode uses GHCR package versions, not GitHub releases
229241
if deployMode == "docker" {
@@ -373,9 +385,30 @@ For more information, see: https://github.com/altuslabsxyz/devnet-builder/blob/m
373385
// customBinaryPath already set from unified selection - use it directly
374386
logger.Success("Using selected binary: %s", customBinaryPath)
375387
}
388+
389+
// Handle --export-version flag for separate export binary
390+
// This allows using a different binary version for genesis export
391+
if deployExportVersion != "" {
392+
logger.Info("Building export binary version: %s", deployExportVersion)
393+
buildResult, err := buildBinaryForDeploy(ctx, deployBlockchainNetwork, deployExportVersion, deployNetwork, logger)
394+
if err != nil {
395+
return fmt.Errorf("failed to build export binary: %w", err)
396+
}
397+
exportBinaryPath = buildResult.BinaryPath
398+
commitShort := buildResult.CommitHash
399+
if len(commitShort) > 12 {
400+
commitShort = commitShort[:12]
401+
}
402+
logger.Success("Export binary ready (version: %s, commit: %s)", deployExportVersion, commitShort)
403+
} else {
404+
// No export version specified - use start binary for export too
405+
exportBinaryPath = customBinaryPath
406+
}
376407
}
377408

378409
// Phase 1: Provision using DevnetService
410+
// Note: BinaryPath is used for genesis export, CustomBinaryPath is used for node startup
411+
// When --export-version is specified, these may be different binaries
379412
provisionInput := dto.ProvisionInput{
380413
HomeDir: homeDir,
381414
Network: deployNetwork,
@@ -386,9 +419,9 @@ For more information, see: https://github.com/altuslabsxyz/devnet-builder/blob/m
386419
StableVersion: startVersion,
387420
DockerImage: dockerImage,
388421
NoCache: deployNoCache,
389-
CustomBinaryPath: customBinaryPath,
422+
CustomBinaryPath: customBinaryPath, // Binary for node startup
390423
UseSnapshot: deployFork,
391-
BinaryPath: customBinaryPath,
424+
BinaryPath: exportBinaryPath, // Binary for genesis export (may differ with --export-version)
392425
UseTestMnemonic: deployTestMnemonic,
393426
}
394427

0 commit comments

Comments
 (0)