1
1
mirror of https://github.com/wader/fq.git synced 2024-12-22 21:01:37 +03:00

fq: Embed version in source

Related to #68
This commit is contained in:
Mattias Wadman 2022-01-19 12:20:52 +01:00
parent 059e287227
commit 78c0775e63
3 changed files with 8 additions and 5 deletions

View File

@ -22,7 +22,6 @@ builds:
ldflags:
# omit symbol table and debug information
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
- -X main.date={{.CommitDate}}
- -X main.builtBy=goreleaser

View File

@ -5,9 +5,8 @@ GO_TEST_RACE_FLAGS ?=-race
all: test fq
.PHONY: fq
fq: VERSION=$(shell git describe --all --long --dirty 2>/dev/null || echo nogit)
fq:
CGO_ENABLED=0 go build -o fq -ldflags "${GO_BUILD_LDFLAGS} -X main.version=${VERSION}" ${GO_BUILD_FLAGS} .
CGO_ENABLED=0 go build -o fq -ldflags "${GO_BUILD_LDFLAGS}" ${GO_BUILD_FLAGS} .
.PHONY: test
test: testgo testjq testcli
@ -112,6 +111,12 @@ release:
@echo make lint test doc
@echo go mod tidy
@echo git diff
@echo
@echo "sed 's/version = "\\\(.*\\\)"/version = \"${VERSION}\"/' fq.go > fq.go.new && mv fq.go.new fq.go"
@echo git add fq.go
@echo git commit -m "fq: Update version to ${VERSION}"
@echo git push wader master
@echo
@echo "# make sure head master commit CI was successful"
@echo open https://github.com/wader/fq/commit/master
@echo git tag v${VERSION}
@ -127,4 +132,3 @@ release:
@echo "# wader/fq":
@echo git push wader v${VERSION}:v${VERSION}
@echo "# edit draft release notes and publish"
@echo open https://github.com/wader/fq/releases/tag/v${VERSION}

2
fq.go
View File

@ -6,7 +6,7 @@ import (
"github.com/wader/fq/pkg/cli"
)
var version = "dev"
const version = "0.0.3"
func main() {
cli.Main(registry.Default, version)