Skip to content

Commit

Permalink
refactor makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Liam Stanley <[email protected]>
  • Loading branch information
lrstanley committed Aug 1, 2022
1 parent 5d6facc commit e07adb5
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
.DEFAULT_GOAL := build
BINARY=vault-unseal

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}'
export PROJECT := "vault-unseal"

fetch: ## Fetches the necessary dependencies to build.
license:
curl -sL https://liam.sh/-/gh/g/license-header.sh | bash -s

fetch:
go mod download
go mod tidy

upgrade-deps: ## Upgrade all dependencies to the latest version.
upgrade-deps:
go get -u ./...
go mod tidy

upgrade-deps-patch: ## Upgrade all dependencies to the latest patch release.
upgrade-deps-patch:
go get -u=patch ./...
go mod tidy

clean: ## Cleans up generated files/folders from the build.
/bin/rm -rfv "dist/" "${BINARY}"
clean:
/bin/rm -rfv "dist/" "${PROJECT}"

debug: clean
go run *.go

prepare: fetch clean ## Prepare the dependencies needed for a build.

build: prepare ## Compile and generate a binary.
CGO_ENABLED=0 go build -ldflags '-d -s -w -extldflags=-static' -tags=netgo,osusergo,static_build -installsuffix netgo -buildvcs=false -trimpath -o "${BINARY}"
prepare: fetch clean
go generate -x ./...

build: prepare fetch
CGO_ENABLED=0 \
go build \
-ldflags '-d -s -w -extldflags=-static' \
-tags=netgo,osusergo,static_build \
-installsuffix netgo \
-buildvcs=false \
-trimpath \
-o ${PROJECT}

0 comments on commit e07adb5

Please sign in to comment.