Skip to content

Commit

Permalink
fix(ci): Update goreleaser to write pkg/version/version.Version o…
Browse files Browse the repository at this point in the history
…n build.

Signed-off-by: sbailey <[email protected]>
  • Loading branch information
spbsoluble committed Mar 6, 2024
1 parent 12ad39d commit c7dabb4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ builds:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
- "-X 'kfutil/pkg/version.Version={{.Version}}'"
goos:
- freebsd
- windows
Expand Down
8 changes: 5 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NAME=kfutil
BINARY=${NAME}
VERSION := $(GITHUB_REF_NAME)
ifeq ($(VERSION),)
VERSION := v1.2.1
VERSION := v1.4.1
endif
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
BASEDIR := ${HOME}/go/bin
Expand All @@ -25,7 +25,7 @@ build: fmt

release:
mkdir -p ./bin/${BINARY}_${VERSION}_darwin_amd64
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64/kfutil
GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'pkg/version/version.Version=${VERSION})'" -o ./bin/${BINARY}_${VERSION}_darwin_amd64/kfutil
cp README.md ./bin/${BINARY}_${VERSION}_darwin_amd64
cp LICENSE ./bin/${BINARY}_${VERSION}_darwin_amd64
cp CHANGELOG.md ./bin/${BINARY}_${VERSION}_darwin_amd64
Expand All @@ -45,7 +45,9 @@ release:
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64

install: fmt
go build -o ${BINARY}
#go build -ldflags="-X 'pkg/version/version.Version=${VERSION})'" -o ${BINARY}
go build -ldflags="-X 'kfutil/pkg/version.Version=${VERSION}'" -o ${BINARY}

rm -rf ${INSTALLDIR}/${BINARY}
mkdir -p ${INSTALLDIR}
chmod oug+x ${BINARY}
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var versionCmd = &cobra.Command{
Short: "Shows version of kfutil",
Long: `Shows version of kfutil`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("kfutil version %s", version.VERSION)
fmt.Printf("kfutil version %s", version.Version)
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package version

const VERSION = "1.4.0"
var Version = "1.4.0"

0 comments on commit c7dabb4

Please sign in to comment.