-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
105 lines (79 loc) · 3.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.PHONY: ap
#----------------------------------------------------------------------------------
# Base
#----------------------------------------------------------------------------------
OUTDIR:=_output
SOURCES := $(shell find . -name "*.go" | grep -v test.go | grep -v '\.\#*')
RELEASE := "true"
ifeq ($(TAGGED_VERSION),)
# TAGGED_VERSION := $(shell git describe --tags)
# This doesn't work in CI, need to find another way...
TAGGED_VERSION := vdev
RELEASE := "false"
endif
VERSION ?= $(shell echo $(TAGGED_VERSION) | cut -c 2-)
LDFLAGS := "-X github.com/solo-io/autopilot/pkg/version.Version=$(VERSION)"
GCFLAGS := all="-N -l"
# Passed by cloudbuild
GCLOUD_PROJECT_ID := $(GCLOUD_PROJECT_ID)
BUILD_ID := $(BUILD_ID)
TEST_IMAGE_TAG := test-$(BUILD_ID)
TEST_ASSET_DIR := $(ROOTDIR)/_test
GCR_REPO_PREFIX := gcr.io/$(GCLOUD_PROJECT_ID)
#----------------------------------------------------------------------------------
# Build
#----------------------------------------------------------------------------------
# Build dependencies
.PHONY: generate-deps
generate-deps:
go get -u github.com/gobuffalo/packr/packr
# Generated Code & Docs
.PHONY: generated-code
generated-code:
go generate ./...
# CLI
CLI_DIR=cli
.PHONY: ap
ap: $(OUTDIR)/ap
$(OUTDIR)/ap: $(SOURCES)
go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
.PHONY: ap-linux-amd64
ap-linux-amd64: $(OUTDIR)/ap-linux-amd64
$(OUTDIR)/ap-linux-amd64: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
.PHONY: ap-darwin-amd64
ap-darwin-amd64: $(OUTDIR)/ap-darwin-amd64
$(OUTDIR)/ap-darwin-amd64: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
.PHONY: ap-windows-amd64
ap-windows-amd64: $(OUTDIR)/ap-windows-amd64.exe
$(OUTDIR)/ap-windows-amd64.exe: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ $(CLI_DIR)/cmd/main.go
.PHONY: build-cli
build-cli: ap-linux-amd64 ap-darwin-amd64 ap-windows-amd64
.PHONY: install-cli
install-cli:
go build -o ${GOPATH}/bin/ap $(CLI_DIR)/cmd/main.go
#----------------------------------------------------------------------------------
# Test
#----------------------------------------------------------------------------------
# Build & Run Test Project
.PHONY: test
test:
cd test/e2e && ./run_test_project.sh
#----------------------------------------------------------------------------------
# Release
#----------------------------------------------------------------------------------
# The code does the proper checking for a TAGGED_VERSION
.PHONY: upload-github-release-assets
upload-github-release-assets: build-cli
go run ci/upload_github_release_assets.go
#----------------------------------------------------------------------------------
# Clean
#----------------------------------------------------------------------------------
# Important to clean before pushing new releases. Dockerfiles and binaries may not update properly
.PHONY: clean
clean:
rm -rf codegen/*-packr.go
rm -rf _output
rm -rf test/e2e/canary