Skip to content

Commit c176d9b

Browse files
committed
Set version using git description
1 parent 419b572 commit c176d9b

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

.github/workflows/push-container.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626

2727
# Build docker image
2828
- uses: ko-build/[email protected]
29-
- run: ko build -B --platform all --sbom none ./cmd/ybfeed
29+
- run: GOFLAGS="-ldflags=-X=main.version=`git describe --tags`" ko build -B --platform all --sbom none ./cmd/ybfeed
3030
env:
3131
KO_DOCKER_REPO: ghcr.io/ybizeul

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ jobs:
4444

4545
# Build docker image
4646
- uses: ko-build/[email protected]
47-
- run: ko build -B --platform all --sbom none --tags "`git describe`,latest" ./cmd/ybfeed
47+
- run: GOFLAGS="-ldflags=-X=main.version=`git describe --tags`" ko build -B --platform all --sbom none --tags "`git describe`,latest" ./cmd/ybfeed
4848
env:
4949
KO_DOCKER_REPO: ghcr.io/ybizeul

.goreleaser.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ builds:
1010
- main: ./cmd/ybfeed
1111
env:
1212
- CGO_ENABLED=0
13+
- GOFLAGS="-ldflags=-X=main.version=`git describe --tags`"
1314
goos:
1415
- linux
1516
- windows

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
VERSION = $(shell git describe --tags)
2+
13
all: ui go push
24

35
ui:
@@ -6,15 +8,17 @@ ui:
68
npm run build
79

810
go:
11+
GOFLAGS="-ldflags=-X=main.version=$(VERSION)" \
912
go build -o ybFeed cmd/ybfeed/*.go
1013

1114
ui-run: ui run
1215

1316
run:
17+
GOFLAGS="-ldflags=-X=main.version=$(VERSION)" \
1418
go run cmd/ybfeed/*.go
1519

1620
push:
17-
ko build -B -t `git describe --tags`
21+
GOFLAGS="-ldflags=-X=main.version=$(VERSION)" ko build -B -t $(VERSION)
1822

1923
clean:
2024
rm -f ybFeed

cmd/ybfeed/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package main
22

3-
const version = "0.10"
3+
var version string

0 commit comments

Comments
 (0)