Created
May 13, 2019 04:42
-
-
Save michaeljs1990/21d2249b44b0a4657d3d8695f76083a0 to your computer and use it in GitHub Desktop.
Golang Release Makefile (Gox like with only linux utils)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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