Skip to content

Conversation

@abtreece
Copy link
Owner

Summary

Goreleaser now injects the version from the git tag via ldflags, eliminating the need to manually update version.go before releases.

  • .goreleaser.yml: Add -X main.Version={{ .Version }} to ldflags
  • version.go: Change const to var with "dev" default
  • Makefile: Use git describe for local builds
  • CLAUDE.md: Simplify release process documentation

Test plan

  • Verified with goreleaser snapshot build
  • Verified released v0.33.1 binary shows correct version
  • Local make build produces versioned binary

Fixes #521

Goreleaser now injects the version from the git tag via ldflags,
eliminating the need to manually update version.go before releases.

Changes:
- .goreleaser.yml: Add -X main.Version={{ .Version }} to ldflags
- version.go: Change const to var with "dev" default
- Makefile: Use git describe for local builds
- CLAUDE.md: Simplify release process documentation

Fixes #521
Copilot AI review requested due to automatic review settings January 31, 2026 01:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR automates version injection during builds by using git tags and ldflags, eliminating the need to manually maintain version numbers in source code.

Changes:

  • Configured goreleaser and Makefile to inject version from git tags via ldflags
  • Modified version.go to use variables instead of constants, with "dev" as default
  • Updated documentation to reflect the simplified release workflow

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
cmd/confd/version.go Changed Version from const to var, grouped with GitSHA, added default "dev" value
Makefile Updated VERSION extraction to use git describe and added Version to ldflags
CLAUDE.md Removed manual version.go update steps from release documentation
.goreleaser.yml Added Version variable injection to ldflags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84db6f305a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.PHONY: build install clean lint test integration dep release
VERSION=`egrep -o '[0-9]+\.[0-9a-z.\-]+' cmd/confd/version.go`
GIT_SHA=`git rev-parse --short HEAD || echo`
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo "dev")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve version when git metadata is missing

When building from a source tree without .git (e.g., distro tarballs or vendored source), git describe fails, but the pipeline still exits 0 because sed succeeds, so the || echo "dev" fallback never runs. That leaves VERSION empty and the -ldflags "-X main.Version=$(VERSION)" assignment overwrites the default Version = "dev" with an empty string, so confd --version prints a blank version in those environments. Consider moving the fallback before the pipe or grouping it, e.g., (git describe ... || echo dev) | sed 's/^v//', so non-git builds still get a meaningful version.

Useful? React with 👍 / 👎.

@abtreece abtreece merged commit 48a134e into main Jan 31, 2026
10 of 11 checks passed
@abtreece abtreece deleted the fix/version-injection branch January 31, 2026 01:51
@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.50%. Comparing base (126a9bf) to head (84db6f3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #522      +/-   ##
==========================================
+ Coverage   62.45%   62.50%   +0.05%     
==========================================
  Files          48       48              
  Lines        5420     5420              
==========================================
+ Hits         3385     3388       +3     
+ Misses       1828     1825       -3     
  Partials      207      207              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Looks like you forgot to bump the version number to 0.33.0 when building?

1 participant