community/caddy: missing version number in `caddy version` command
Package Information
- Package name: community/caddy
- Package version: 2.7.6-r3
- Alpine version: edge
- Alpine architecture: x86
Summary
I'm posting here as an upstream maintainer of Caddy.
When users run caddy version
, they see unknown
. This is confusing, because the version should be known.
We've had many users complain about this over the years, but I was never sure where to post or who to ask to fix it. Finally found this gitlab instance. See https://github.com/caddyserver/caddy/issues/6240 for a user's complaint.
Steps to reproduce
- Install
caddy
- run
caddy version
- see
unknown
Solution
There's a few ways to fix this.
- As per our README https://github.com/caddyserver/caddy?tab=readme-ov-file#with-version-information-andor-plugins build using a fresh module and pin to a specific tag. This way you wouldn't need to clone the code, and you could just make use of Go's tooling to build.
- Use our
xcaddy
tool which automates the above steps, e.g.xcaddy build v2.7.6
, obviously this means the build server needs to download and installxcaddy
, so I envision this wouldn't be a preferred solution, but I don't know how your build server works; is it containerized/isolated? if so then this could work fine. - See https://github.com/caddyserver/caddy/pull/5072, we added a
'-X (...).VersionString=v1.2.3'
build flag which can be used to directly set the version number. This is the "worst" solution because it doesn't also embed the info pulled fromgit
, but it would at least show a version number.
/cc @mpolanski @Celeste