Skip to content

Instantly share code, notes, and snippets.

@michaeljs1990
Created May 13, 2019 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeljs1990/21d2249b44b0a4657d3d8695f76083a0 to your computer and use it in GitHub Desktop.
Save michaeljs1990/21d2249b44b0a4657d3d8695f76083a0 to your computer and use it in GitHub Desktop.
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