Skip to content

Commit d2a202b

Browse files
committed
Add versioning support
1 parent dbc904b commit d2a202b

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.github/workflows/publish-container.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
branches:
99
- main
1010
pull_request:
11+
release:
12+
types:
13+
- released
1114

1215
jobs:
1316
publish-docker:
@@ -62,4 +65,5 @@ jobs:
6265
tags: ${{ steps.meta.outputs.tags }}
6366
labels: ${{ steps.meta.outputs.labels }}
6467
file: Containerfile
68+
build-args: version=${{ github.event.release.tag_name || 'dev' }}
6569
push: true

Containerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ RUN go mod download
99

1010
COPY cmd/ cmd/
1111
COPY internal/ internal/
12-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o glci github.com/gardenlinux/glci/cmd
12+
ARG version=dev
13+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o glci \
14+
-ldflags "-X main.version=${version}" github.com/gardenlinux/glci/cmd
1315

1416
FROM docker.io/library/debian:bookworm-20250630-slim
1517
WORKDIR /

cmd/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import (
1212
"github.com/gardenlinux/glci/internal/log"
1313
)
1414

15-
// Version is the released version of GLCI, or "dev".
16-
const Version = "dev"
17-
1815
func main() {
1916
var exitCode int
2017
defer func() {
@@ -24,7 +21,7 @@ func main() {
2421
mainCmd, cfg, err := cmd.Setup("glci", func(c *cobra.Command) {
2522
c.Use = "glci"
2623
c.Short = "GLCI - Garden Linux continuous integration"
27-
c.Version = Version
24+
c.Version = version
2825
c.PersistentFlags().Bool("dev", false, "run in development mode")
2926
c.PersistentFlags().String("config-file", "", "path to configuration file")
3027
c.AddCommand(publishCmd())

cmd/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
var version = "dev"

0 commit comments

Comments
 (0)