Skip to content

Set the version from the git tag at build time - #315

Merged
adamdecaf merged 1 commit into
masterfrom
version-from-git-tag
Dec 2, 2026
Merged

adamdecaf merged 1 commit into
masterfrom
version-from-git-tag

Conversation

@adamdecaf

Copy link
Copy Markdown
Member

Problem

version.go held a fixed version. Each release needed a manual edit of this file. When the edit was missed, the release build used the old version. For example, Docker images were pushed with the old tag.

Change

  • Change Version from a const to a var with the default value dev.
  • Set Version from the git tag with -ldflags "-X github.com/moov-io/metro2.Version=..." in every go build command in the makefile.
  • Read VERSION from the environment, or from git describe --tags --abbrev=0. Use dev when no tag exists.
  • Pass VERSION as a build argument to the Docker builds, and use it in the Dockerfiles.
  • Set VERSION from the tag in the release workflow.
  • Update the README release steps.
  • Remove the git tag -f line from make release. It moved an existing tag.

A release now needs only a tag. Nobody edits version.go.

Test

  • make build VERSION=v8.8.8 builds a binary that reports v8.8.8.
  • go test ./... passes.

@adamdecaf
adamdecaf merged commit 484de84 into master Dec 2, 2026
9 checks passed
@adamdecaf
adamdecaf deleted the version-from-git-tag branch December 2, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant