Makefile 772 B

12345678910111213141516
  1. GO ?= go
  2. SHELL := bash
  3. IMAGE_TAG ?= $(shell ./tools/image-tag)
  4. GIT_REVISION := $(shell git rev-parse --short HEAD)
  5. GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
  6. GIT_LAST_COMMIT_DATE := $(shell git log -1 --date=iso-strict --format=%cd)
  7. GORELEASER_ENV := GIT_BRANCH=$(GIT_BRANCH) GIT_REVISION=$(GIT_REVISION) GIT_LAST_COMMIT_DATE=$(GIT_LAST_COMMIT_DATE) IMAGE_TAG=$(IMAGE_TAG)
  8. # Build flags
  9. VPREFIX := github.com/opencost/opencost/pkg/build
  10. GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(IMAGE_TAG) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildDate=$(GIT_LAST_COMMIT_DATE)
  11. GO_FLAGS := -ldflags "-extldflags \"-static\" -s -w $(GO_LDFLAGS)"
  12. .PHONY: go/bin
  13. go/bin:
  14. CGO_ENABLED=0 $(GO) build $(GO_FLAGS) ./cmd/costmodel