github.com/wynshop-open-source/gomplate@v3.5.0+incompatible/Makefile (about) 1 .DEFAULT_GOAL = build 2 extension = $(patsubst windows,.exe,$(filter windows,$(1))) 3 GO := go 4 PKG_NAME := gomplate 5 PREFIX := . 6 7 ifeq ("$(CI)","true") 8 LINT_PROCS ?= 1 9 else 10 LINT_PROCS ?= $(shell nproc) 11 endif 12 13 COMMIT ?= `git rev-parse --short HEAD 2>/dev/null` 14 VERSION ?= `git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1) 2>/dev/null | sed 's/v\(.*\)/\1/'` 15 BUILD_DATE ?= `date -u +"%Y-%m-%dT%H:%M:%SZ"` 16 17 COMMIT_FLAG := -X `go list ./version`.GitCommit=$(COMMIT) 18 VERSION_FLAG := -X `go list ./version`.Version=$(VERSION) 19 BUILD_DATE_FLAG := -X `go list ./version`.BuildDate=$(BUILD_DATE) 20 21 GOOS ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/') 22 GOARCH ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/') 23 24 platforms := freebsd-amd64 linux-amd64 linux-386 linux-arm linux-arm64 darwin-amd64 solaris-amd64 windows-amd64.exe windows-386.exe 25 compressed-platforms := linux-amd64-slim linux-arm-slim linux-arm64-slim darwin-amd64-slim windows-amd64-slim.exe 26 27 clean: 28 rm -Rf $(PREFIX)/bin/* 29 rm -f $(PREFIX)/*.[ci]id 30 31 build-x: $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%,$(platforms)) 32 33 compress-all: $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%,$(compressed-platforms)) 34 35 $(PREFIX)/bin/$(PKG_NAME)_%-slim: $(PREFIX)/bin/$(PKG_NAME)_% 36 upx --lzma $< -o $@ 37 38 $(PREFIX)/bin/$(PKG_NAME)_%-slim.exe: $(PREFIX)/bin/$(PKG_NAME)_%.exe 39 upx --lzma $< -o $@ 40 41 $(PREFIX)/bin/$(PKG_NAME)_%_checksum.txt: $(PREFIX)/bin/$(PKG_NAME)_% 42 @sha256sum $< > $@ 43 44 $(PREFIX)/bin/checksums.txt: \ 45 $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum.txt,$(platforms)) \ 46 $(patsubst %,$(PREFIX)/bin/$(PKG_NAME)_%_checksum.txt,$(compressed-platforms)) 47 @cat $^ > $@ 48 49 $(PREFIX)/%.signed: $(PREFIX)/% 50 @keybase sign < $< > $@ 51 52 compress: $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH)-slim$(call extension,$(GOOS)) 53 cp $< $(PREFIX)/bin/$(PKG_NAME)-slim$(call extension,$(GOOS)) 54 55 %.iid: Dockerfile 56 @docker build \ 57 --build-arg BUILD_DATE=$(BUILD_DATE) \ 58 --build-arg VCS_REF=$(COMMIT) \ 59 --target $(subst .iid,,$@) \ 60 --iidfile $@ \ 61 . 62 63 %.cid: %.iid 64 @docker create $(shell cat $<) > $@ 65 66 build-release: artifacts.cid 67 @docker cp $(shell cat $<):/bin/. bin/ 68 69 docker-images: gomplate.iid gomplate-slim.iid 70 71 $(PREFIX)/bin/$(PKG_NAME)_%: $(shell find $(PREFIX) -type f -name "*.go") 72 GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- | cut -f1 -d.) CGO_ENABLED=0 \ 73 $(GO) build \ 74 -ldflags "-w -s $(COMMIT_FLAG) $(VERSION_FLAG) $(BUILD_DATE_FLAG)" \ 75 -o $@ \ 76 ./cmd/gomplate 77 78 $(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS)): $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH)$(call extension,$(GOOS)) 79 cp $< $@ 80 81 build: $(PREFIX)/bin/$(PKG_NAME)$(call extension,$(GOOS)) 82 83 ifeq ($(OS),Windows_NT) 84 test: 85 $(GO) test -v -coverprofile=c.out ./... 86 else 87 test: 88 $(GO) test -v -race -coverprofile=c.out ./... 89 endif 90 91 integration: build 92 $(GO) test -v -tags=integration \ 93 ./tests/integration -check.v 94 95 integration.iid: Dockerfile.integration $(PREFIX)/bin/$(PKG_NAME)_linux-amd64$(call extension,$(GOOS)) 96 docker build -f $< --iidfile $@ . 97 98 test-integration-docker: integration.iid 99 docker run -it --rm $(shell cat $<) 100 101 gen-changelog: 102 docker run -it -v $(shell pwd):/app --workdir /app -e CHANGELOG_GITHUB_TOKEN hairyhenderson/github_changelog_generator \ 103 github_changelog_generator --no-filter-by-milestone --exclude-labels duplicate,question,invalid,wontfix,admin 104 105 docs/themes/hugo-material-docs: 106 git clone https://github.com/digitalcraftsman/hugo-material-docs.git $@ 107 108 gen-docs: docs/themes/hugo-material-docs 109 cd docs/; hugo 110 111 docs/content/functions/%.md: docs-src/content/functions/%.yml docs-src/content/functions/func_doc.md.tmpl 112 gomplate -d data=$< -f docs-src/content/functions/func_doc.md.tmpl -o $@ 113 114 # this target doesn't usually get used - it's mostly here as a reminder to myself 115 # hint: make sure CLOUDCONVERT_API_KEY is set ;) 116 gomplate.png: gomplate.svg 117 cloudconvert -f png -c density=288 $^ 118 119 lint: 120 golangci-lint run --disable-all \ 121 --enable depguard \ 122 --enable dupl \ 123 --enable goconst \ 124 --enable gocritic \ 125 --enable gocyclo \ 126 --enable gofmt \ 127 --enable goimports \ 128 --enable golint \ 129 --enable gosec \ 130 --enable gosimple \ 131 --enable govet \ 132 --enable ineffassign \ 133 --enable maligned \ 134 --enable misspell \ 135 --enable nakedret \ 136 --enable prealloc \ 137 --enable staticcheck \ 138 --enable structcheck \ 139 --enable stylecheck \ 140 --enable typecheck \ 141 --enable unconvert \ 142 --enable varcheck 143 144 golangci-lint run --tests=false --disable-all \ 145 --enable deadcode \ 146 --enable errcheck \ 147 --enable interfacer \ 148 --enable scopelint \ 149 --enable unused 150 151 golangci-lint run --build-tags integration \ 152 --disable-all \ 153 --enable deadcode \ 154 --enable depguard \ 155 --enable dupl \ 156 --enable gochecknoinits \ 157 --enable gocritic \ 158 --enable gocyclo \ 159 --enable gofmt \ 160 --enable goimports \ 161 --enable golint \ 162 --enable gosec \ 163 --enable gosimple \ 164 --enable govet \ 165 --enable ineffassign \ 166 --enable maligned \ 167 --enable misspell \ 168 --enable nakedret \ 169 --enable prealloc \ 170 --enable scopelint \ 171 --enable staticcheck \ 172 --enable structcheck \ 173 --enable stylecheck \ 174 --enable typecheck \ 175 --enable unconvert \ 176 --enable unparam \ 177 --enable unused \ 178 --enable varcheck \ 179 ./tests/integration 180 181 .PHONY: gen-changelog clean test build-x compress-all build-release build test-integration-docker gen-docs lint clean-images clean-containers docker-images 182 .DELETE_ON_ERROR: 183 .SECONDARY: