-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (108 loc) · 3.16 KB
/
Makefile
File metadata and controls
132 lines (108 loc) · 3.16 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.PHONY: upload_dists
GIT_VERSION?=$(shell git describe --tags --always --abbrev=42 --dirty)
CACHE?=~/.cache
GOOS?=linux
GOARCH?=amd64
export COMPOSE=docker-compose -f docker-compose.yml
$(CACHE):
mkdir -p $(CACHE)
binary: bin
go build \
-ldflags " \
-X github.com/factorysh/factory-cli/version.version=$(GIT_VERSION) \
-X github.com/factorysh/factory-cli/version.os=$(GOOS) \
-X github.com/factorysh/factory-cli/version.arch=$(GOARCH) \
" \
-o bin/factory \
main.go
install: binary
cp bin/factory /usr/local/bin/
build/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION):
env GOOS=$(GOOS) GOARCH=$(GOARCH) \
go build \
-ldflags " \
-X github.com/factorysh/factory-cli/version.version=$(GIT_VERSION) \
-X github.com/factorysh/factory-cli/version.os=$(GOOS) \
-X github.com/factorysh/factory-cli/version.arch=$(GOARCH) \
" \
-o build/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION) \
main.go
dist/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION).gz: build/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION)
gzip -c build/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION) > \
dist/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION).gz
release: build dist dist/factory-$(GOOS)-$(GOARCH)-$(GIT_VERSION).gz
releases:
make release GOOS=windows GOARCH=amd64
make release GOOS=linux GOARCH=amd64
make release GOOS=darwin GOARCH=amd64
venv:
python3 -m venv venv
./venv/bin/pip install requests
upload_dists: venv
./venv/bin/python upload_dists
new_tag:
# check invalid tag name
echo $(GIT_VERSION) | grep -E "^v[0-9].[0-9].[0-9]" || false
# fail if tag exists
git tag | grep $(GIT_VERSION) || true
git tag $(GIT_VERSION)
git checkout $(GIT_VERSION)
new_release: new_tag docker-binaries upload_dists
git checkout master
bin:
mkdir -p bin
dist:
mkdir -p dist
build:
mkdir -p build
test:
go test -v \
github.com/factorysh/factory-cli/client \
github.com/factorysh/factory-cli/gitlab
docker-build: $(CACHE)
docker run --rm \
-u `id -u` \
-v $(CACHE):/.cache \
-v `pwd`:/go/src/github.com/factorysh/factory-cli \
-w /go/src/github.com/factorysh/factory-cli \
-e GIT_VERSION=$(GIT_VERSION) \
bearstech/golang-dep \
make binary
docker-binaries: $(CACHE)
docker run --rm \
-u `id -u` \
-v $(CACHE):/.cache \
-v `pwd`:/go/src/github.com/factorysh/factory-cli \
-w /go/src/github.com/factorysh/factory-cli \
-e GIT_VERSION=$(GIT_VERSION) \
bearstech/golang-dep \
make releases
docker-test: $(CACHE)
docker run --rm \
-u `id -u` \
-v $(CACHE):/.cache \
-v `pwd`:/go/src/github.com/factorysh/factory-cli \
-w /go/src/github.com/factorysh/factory-cli \
bearstech/golang-dep \
make test
docker-test-runjob: docker-build
bin/factory runjob -h
bin/factory runjob -D job1
bin/factory runjob -v job1
bin/factory runjob -D job2
bin/factory runjob job2
bin/factory runjob -D job3
bin/factory runjob job3
bin/factory runjob notfound || true
test-sftp: docker-build
echo get ./data/volume/test /tmp/test | \
PRIVATE_TOKEN=$(PRIVATE_TOKEN) ./bin/factory \
volume sftp \
-p factory/factory-canary -e staging
test-exec: docker-build
PRIVATE_TOKEN=$(PRIVATE_TOKEN) ./bin/factory \
container exec \
-p factory/factory-canary -e staging \
web -- ls -l
clean:
rm -rf bin vendor build dist mysql-*.gz