computed "version" {
description = "Application version from the VERSION file"
expression = trimspace(file("VERSION"))
}
task "build" {
description = "Build the binary with the version embedded"
commands = [
"go build -ldflags \"-X main.version=${computed.version}\" -o bin/app ./cmd/app",
]
}
task "docker-build" {
description = "Build and tag the Docker image"
depends_on = [task.build]
commands = [
"docker build -t myapp:${computed.version} .",
"docker tag myapp:${computed.version} myapp:latest",
]
}