Commit 03c0061b authored by protolambda's avatar protolambda

devnet: set git commit/date build-args, handle op-program/challenger/node version format cases

parent a0d6c4c5
......@@ -94,8 +94,13 @@ def main():
devnet_l1_genesis(paths)
return
log.info('Building docker images')
run_command(['docker', 'compose', 'build', '--progress', 'plain'], cwd=paths.ops_bedrock_dir, env={
git_commit = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True, text=True).stdout.strip()
git_date = subprocess.run(['git', 'show', '-s', "--format='%ct'"], capture_output=True, text=True).stdout.strip()
log.info(f'Building docker images for git commit {git_commit} ({git_date})')
run_command(['docker', 'compose', 'build', '--progress', 'plain',
'--build-arg', f'GIT_COMMIT={git_commit}', '--build-arg', f'GIT_DATE={git_date}'],
cwd=paths.ops_bedrock_dir, env={
'PWD': paths.ops_bedrock_dir,
'DOCKER_BUILDKIT': '1', # (should be available by default in later versions, but explicitly enable it anyway)
'COMPOSE_DOCKER_CLI_BUILD': '1' # use the docker cache
......
......@@ -24,7 +24,11 @@ var (
var VersionWithMeta = func() string {
v := version.Version
if GitCommit != "" {
v += "-" + GitCommit[:8]
if len(GitCommit) >= 8 {
v += "-" + GitCommit[:8]
} else {
v += "-" + GitCommit
}
}
if GitDate != "" {
v += "-" + GitDate
......
......@@ -31,10 +31,12 @@ var (
// VersionWithMeta holds the textual version string including the metadata.
var VersionWithMeta = func() string {
v := version.Version
if len(GitCommit) >= 8 {
v += "-" + GitCommit[:8]
} else {
v += "-" + GitCommit
if GitCommit != "" {
if len(GitCommit) >= 8 {
v += "-" + GitCommit[:8]
} else {
v += "-" + GitCommit
}
}
if GitDate != "" {
v += "-" + GitDate
......
......@@ -21,7 +21,11 @@ var (
var VersionWithMeta = func() string {
v := version.Version
if GitCommit != "" {
v += "-" + GitCommit[:8]
if len(GitCommit) >= 8 {
v += "-" + GitCommit[:8]
} else {
v += "-" + GitCommit
}
}
if GitDate != "" {
v += "-" + GitDate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment