Skip to content

Commit

Permalink
Add in the version number to the released binary
Browse files Browse the repository at this point in the history
  • Loading branch information
benmatselby committed Aug 26, 2023
1 parent a67dde3 commit fd8de4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
linux/arm64
linux/amd64
linux/386
solaris/amd64
windows/amd64
windows/386
)
Expand All @@ -47,7 +46,7 @@ jobs:
echo "\n\nBuilding binary for ${GOOS}/${ARCH}\n"
GOOS=${GOOS} GOARCH=${ARCH} make static-named
GIT_RELEASE=${{ github.event.release.tag_name }} GOOS=${GOOS} GOARCH=${ARCH} make static-named
done
gh release upload ${{ github.event.release.tag_name }} build/*
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## next

## 2.8.0

- Allow the caller of `make docker-build` to specify the Docker platform.
- Add in the release version to the auto-generated binaries during a release.

## 2.7.0

Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ BUILD_DIR ?= build
GOOS ?=
ARCH ?=
OUT_PATH=$(BUILD_DIR)/$(NAME)-$(GOOS)-$(GOARCH)
GIT_RELEASE ?= $(shell git rev-parse --short HEAD)

.PHONY: explain
explain:
Expand All @@ -24,8 +25,6 @@ explain:
### Targets
@cat Makefile* | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

GITCOMMIT := $(shell git rev-parse --short HEAD)

.PHONY: clean
clean: ## Clean the local dependencies
rm -fr vendor
Expand All @@ -52,13 +51,13 @@ build: ## Build the application

.PHONY: static
static: ## Build the application
CGO_ENABLED=0 go build -ldflags "-extldflags -static -X github.com/benmatselby/$(NAME)/version.GITCOMMIT=$(GITCOMMIT)" -o $(NAME) .
CGO_ENABLED=0 go build -ldflags "-extldflags -static -X github.com/benmatselby/$(NAME)/version.GITCOMMIT=$(GIT_RELEASE)" -o $(NAME) .

.PHONY: static-named
static-named: ## Build the application with named outputs
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 \
go build \
-ldflags "-extldflags -static -X github.com/benmatselby/$(NAME)/version.GITCOMMIT=$(GITCOMMIT)" \
-ldflags "-extldflags -static -X github.com/benmatselby/$(NAME)/version.GITCOMMIT=$(GIT_RELEASE)" \
-o $(OUT_PATH) .

md5sum $(OUT_PATH) > $(OUT_PATH).md5 || md5 $(OUT_PATH) > $(OUT_PATH).md5
Expand Down

0 comments on commit fd8de4e

Please sign in to comment.