ENG-7Recommended
Stamp every build with its version
Give every build a version and the commit it came from. Show both in the running app, and tag each release in version control.
How to do it
Pass the version and commit hash into the build, for example as build arguments or a generated file. Never type them by hand. Return them from a version address or the health check, and add them to every log line and error report. Tag the commit of every production release, such as v2026.10.20-1 or a semantic version for a library. Send the version to the dashboards as a deploy marker.
Examples
Shell example
docker build --build-arg VERSION="$(git describe --tags --always)" --build-arg COMMIT="$(git rev-parse HEAD)" .
JavaScript example
// The Dockerfile turns the build arguments into environment variables
app.get('/version', (req, res) => {
res.json({ version: process.env.VERSION, commit: process.env.COMMIT });
});
Python example
# Flask
@app.get("/version")
def version():
return {"version": os.environ["VERSION"], "commit": os.environ["COMMIT"]}
Go example
// Set at build time: go build -ldflags "-X main.commit=$(git rev-parse HEAD)"
var commit = "unknown"
http.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]string{"commit": commit})
})
How to check
After a deploy, the version address returns the commit hash of the deployed commit. git tag --points-at <that commit> prints the release tag.
Sources
Related rules
- ENG-9 Give the server a health check in Engineering
- OPS-17 Record deploys on the graphs in Operations and observability
- ENG-42 Make release tags and files immutable in Engineering
- MOB-2 Describe every change in the review notes in Mobile apps
- MOB-9 Raise the build number on every upload in Mobile apps
- DEV-8 Give every command help with an example and a version flag in Developer tools, SDKs and CLIs
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/engineering/build-test-and-deploy/version-every-release">Agent Wranglers engineering playbook</a>. In code you write, add a comment next to it with the same link.