File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 GOARCH : ${{ matrix.arch }}
3535 run : |
3636 cd cmd/gitops
37- go build -ldflags="-s -w" .
37+ go build -ldflags="-s -w -X 'main.version=${{ github.ref_name }}' " .
3838 - name : Upload binaries to release
3939 uses : svenstaro/upload-release-action@v2
4040 with :
6969 with :
7070 platforms : linux/amd64
7171 push : true
72+ build-args : |
73+ GITOPS_VERSION=${{ github.ref_name }}
7274 tags : ghcr.io/mxcd/gitops/${{ matrix.image }}:${{ github.ref_name }}
7375 file : docker/${{ matrix.image }}/Dockerfile
Original file line number Diff line number Diff line change @@ -15,10 +15,19 @@ import (
1515 "github.com/urfave/cli/v2"
1616)
1717
18+ var version = "development"
19+
1820func main () {
21+ cli .VersionFlag = & cli.BoolFlag {
22+ Name : "version" ,
23+ Aliases : []string {},
24+ Usage : "print only the version" ,
25+ }
26+
1927 app := & cli.App {
20- Name : "gitpos" ,
21- Usage : "GitOps CLI" ,
28+ Name : "gitpos" ,
29+ Version : version ,
30+ Usage : "GitOps CLI" ,
2231 Flags : []cli.Flag {
2332 & cli.StringFlag {
2433 Name : "root-dir" ,
Original file line number Diff line number Diff line change 11FROM golang:1.24-alpine3.20 AS builder
22RUN apk add --no-cache git
33
4+ ARG GITOPS_VERSION="development"
5+
46WORKDIR /usr/src
57COPY go.mod /usr/src/go.mod
68COPY go.sum /usr/src/go.sum
@@ -10,7 +12,7 @@ COPY cmd cmd
1012COPY internal internal
1113
1214WORKDIR /usr/src/cmd/gitops
13- RUN go build -o gitops -ldflags="-s -w" .
15+ RUN go build -o gitops -ldflags="-s -w 'main.version=${GITOPS_VERSION}' " .
1416
1517FROM alpine:3.20
1618WORKDIR /usr/bin
You can’t perform that action at this time.
0 commit comments