fix: report actual version instead of hardcoded 3.0.0-dev
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

- Add version variable to main.go, set via -X ldflags at build time
- Pass version through to Server, used in the / endpoint response
- Makefile passes VERSION from git describe
- Dockerfile accepts VERSION build arg
- Woodpecker passes CI_COMMIT_TAG as VERSION
This commit is contained in:
2026-06-27 00:47:52 +10:00
parent 8ec7de50e3
commit ab2b7ed5ac
5 changed files with 12 additions and 5 deletions
+4 -2
View File
@@ -35,6 +35,7 @@ import (
type Server struct {
cfg *config.Config
version string
router chi.Router
db *database.DB
cache *cache.Redis
@@ -45,7 +46,7 @@ type Server struct {
gc *gc.Collector
}
func New(cfg *config.Config) (*Server, error) {
func New(cfg *config.Config, version string) (*Server, error) {
db, err := database.New(cfg.DatabaseDSN())
if err != nil {
return nil, fmt.Errorf("database: %w", err)
@@ -68,6 +69,7 @@ func New(cfg *config.Config) (*Server, error) {
s := &Server{
cfg: cfg,
version: version,
db: db,
cache: redis,
store: s3,
@@ -138,7 +140,7 @@ func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
func (s *Server) handleRoot(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, `{"name":"artifactapi","version":"3.0.0-dev"}`)
fmt.Fprintf(w, `{"name":"artifactapi","version":"%s"}`, s.version)
}
func (s *Server) newHTTPServer() *http.Server {