Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Golang Release Makefile (Gox like with only linux utils)
BINS_DIR = bins
VERSION = $(shell git describe --tag --dirty)
SRC = $(shell find . -type f -name '*.go')
# Set the GOOS and GOARCH here in GOOS_GOARCH format
PLATFORMS = \
linux_amd64
BINS_OUT = $(patsubst %, $(BINS_DIR)/$(VERSION)/jsonnet-%, $(PLATFORMS))
$(BINS_DIR)/$(VERSION):
mkdir -p $(BINS_DIR)/$(VERSION)
$(BINS_OUT): $(BINS_DIR)/$(VERSION) $(SRC)
$(eval BINARY = $(notdir $@))
$(eval PARTS = $(word 2, $(subst -, ,$(BINARY))))
$(eval BUILD = $(subst _, ,$(PARTS)))
CGO_ENABLED=0 GOOS=$(word 1, $(BUILD)) GOARCH=$(word 2, $(BUILD)) go build -o $@ ./cmd/jsonnet
.PHONY: release
release: $(BINS_OUT)
.PHONY: clean
clean:
rm -rf $(BINS_DIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.