Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: Use newly-available version information #4931

Merged
merged 2 commits into from
Aug 4, 2022
Merged

cmd: Use newly-available version information #4931

merged 2 commits into from
Aug 4, 2022

Conversation

mholt
Copy link
Member

@mholt mholt commented Aug 4, 2022

Closes #4926

New Version() function returns simple and full version strings.

Go module information is still preferred. Then vcs info.

It's kind of weird, in that different ways of building Caddy give different outputs:

$ go run main.go version
unknown

$ go build && ./caddy version
496c88864c6b029b7d2c1017ec47ae86fe73045a (04 Aug 22 06:06 UTC)

$ xcaddy build --with github.com/caddyserver/caddy/v2=. && ./caddy version
v2.5.2 => /home/matt/Dev/caddyserver/caddy@(devel)

go run doesn't embed vcs in it, presumably because it runs from outside the git repo?

go build at least embeds commit info, so that's nice. That will still add a lot of helpful version info where we are currently lacking it in bug reports, etc.

xcaddy build of course builds Caddy as a dependency rather than as the main module, so we get the Go module version information, which is the most detailed as it gives us information about module replacements, etc.

So the caddy version command will print the full version string with a little more info.

The short form of the version string also returned by Version() looks like this if it uses VCS info: 63c7720e-20220802 -- it's a shortened SHA with the commit date, for convenience. This would be used for things like User-Agent strings, metrics, etc: Caddy/63c7720e-20220802

Overall, this is definitely an improvement. We're still waiting on golang/go#29228 and golang/go#50603 for a more ideal solution that always makes version info available for the Main module. But this'll do for now.

(Oh, totally forgot in the commit message, but we also just use BuildInfo.String() for caddy build-info now, instead of crafting our own output format. The String() output is quite nice!)

Close #4926

New Version() function returns a simple and full version string.

Go module information is still preferred. Then vcs info.
@mholt mholt added the feature ⚙️ New feature or request label Aug 4, 2022
@mholt mholt added this to the v2.5.3 milestone Aug 4, 2022
@mholt mholt merged commit 17ae5ac into master Aug 4, 2022
@mholt mholt deleted the version branch August 4, 2022 17:17
WilczynskiT pushed a commit to WilczynskiT/caddy that referenced this pull request Aug 17, 2022
@mholt mholt modified the milestones: v2.6.0-beta.1, v2.6.0 Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve caddy version to include revision information
1 participant