forked from hortonworks/cloudbreak-deployer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
174 lines (136 loc) · 5.74 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
NAME=cloudbreak-deployer
BINARYNAME=cbd
ARTIFACTS=LICENSE.txt NOTICE.txt VERSION README
ARCH=$(shell uname -m)
VERSION_FILE=$(shell cat VERSION)
GIT_REV=$(shell git rev-parse --short HEAD)
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
GIT_TAG=$(shell git describe --exact-match --tags 2>/dev/null )
S3_TARGET?=s3://public-repo-1.hortonworks.com/HDP/cloudbreak/
#S3_TARGET=s3://public-repo.sequenceiq.com
# if on a git tag, use that as a version number
ifeq ($(GIT_TAG),)
VERSION=$(VERSION_FILE)-$(GIT_BRANCH)
else
VERSION=$(GIT_TAG)
endif
# if on release branch dont use git revision
ifeq ($(GIT_BRANCH), release)
FLAGS="-X main.Version=$(VERSION)"
VERSION=$(VERSION_FILE)
else
FLAGS="-X main.Version=$(VERSION) -X main.GitRevision=$(GIT_REV)"
endif
echo_version:
echo GIT_TAG[$(GIT_TAG)]
ifeq ($(GIT_TAG),)
echo EMPTY TAG
else
echo NOT_EMPTY_TAG
endif
echo VERSION=$(VERSION)
update-container-versions:
sed -i "0,/DOCKER_TAG_PERISCOPE/ s/DOCKER_TAG_PERISCOPE .*/DOCKER_TAG_PERISCOPE $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_CLOUDBREAK/ s/DOCKER_TAG_CLOUDBREAK .*/DOCKER_TAG_CLOUDBREAK $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_ULUWATU/ s/DOCKER_TAG_ULUWATU .*/DOCKER_TAG_ULUWATU $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_SULTANS/ s/DOCKER_TAG_SULTANS .*/DOCKER_TAG_SULTANS $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_CLOUDBREAK_SHELL/ s/DOCKER_TAG_CLOUDBREAK_SHELL .*/DOCKER_TAG_CLOUDBREAK_SHELL $(CB_VERSION)/" include/cloudbreak.bash
push-container-versions: update-container-versions
git add include/cloudbreak.bash
git commit -m "Updated container versions to $(CB_VERSION)"
git tag $(CB_VERSION)
git push origin HEAD:$(GIT_BRANCH) --tags
build: bindata ## Creates linux an osx binaries in "build/$OS"
mkdir -p build/Linux && GOOS=linux go build -ldflags $(FLAGS) -o build/Linux/$(BINARYNAME)
mkdir -p build/Darwin && GOOS=darwin go build -ldflags $(FLAGS) -o build/Darwin/$(BINARYNAME)
create-snapshot-tgz: ## Creates snapshot tgz from binaries into snapshot dir
rm -rf snapshots
mkdir -p snapshots
tar -czf snapshots/cloudbreak-deployer_snapshot_Linux_x86_64.tgz -C build/Linux cbd
tar -czf snapshots/cloudbreak-deployer_snapshot_Darwin_x86_64.tgz -C build/Darwin cbd
upload-snapshot: create-snapshot-tgz
@echo upload snapshot artifacts to $(S3_TARGET) ...
@docker run \
-v $(PWD):/data \
-w /data \
-e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
-e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
anigeo/awscli s3 cp snapshots/ $(S3_TARGET) --recursive --include "$(NAME)_$(VERSION)_*.tgz"
rm -rf snapshots
dev: bindata
go build -ldflags $(FLAGS) -o /usr/local/bin/$(BINARYNAME)
dev-debug: deps-bindata ## Installs dev version into /usr/local/bin. bash scripts are linked, so changes are effective without new build
go-bindata -debug=true include .deps/bin
go build -ldflags $(FLAGS) -o /usr/local/bin/$(BINARYNAME)
bindata: deps-bindata
go-bindata include .deps/bin
install: build ## Installs OS specific binary into: /usr/local/bin
install build/$(shell uname -s)/$(BINARYNAME) /usr/local/bin
deps-bindata:
ifeq ($(shell which go-bindata),)
go get -u github.com/jteeuwen/go-bindata/...
endif
deps: deps-bindata ## Installs required cli tools (only needed for new envs)
go get -u github.com/progrium/gh-release/...
go get -u github.com/kardianos/govendor
go get github.com/progrium/basht
# go get github.com/github/hub
go get || true
tests:
basht include/*.bash test/*.bash
integration-tests:
basht include/*.bash integration-test/*.bash
integration-tests-centos:
docker build -f Dockerfile.integrationtest -t cbd:integration .
docker run -it --rm \
-v $(PWD):$(PWD) \
-w $(PWD) \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/local/bin/docker:/usr/local/bin/docker \
-e CBD_TMPDIR=$(PWD)/delme-centos \
cbd:integration make integration-tests
cbd:integration make integration-tests
install-test:
docker rmi cbd:delme 2>/dev/null || true
docker build -f Dockerfile.installtest -t cbd:delme .
docker run --rm cbd:delme cbd --version
prepare-release: build
rm -rf release && mkdir release
cp $(ARTIFACTS) build/Linux/
tar -zcf release/$(NAME)_$(VERSION)_Linux_$(ARCH).tgz -C build/Linux $(ARTIFACTS) $(BINARYNAME)
cp $(ARTIFACTS) build/Darwin/
tar -zcf release/$(NAME)_$(VERSION)_Darwin_$(ARCH).tgz -C build/Darwin $(ARTIFACTS) $(BINARYNAME)
upload-release: prepare-release
@echo upload artifacts to $(S3_TARGET) ...
@docker run \
-v $(PWD):/data \
-w /data \
-e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
-e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
anigeo/awscli s3 cp release/ $(S3_TARGET) --recursive --include "$(NAME)_$(VERSION)_*.tgz"
upload-tagged: prepare-release
@echo upload artifacts to $(S3_TARGET) ...
@docker run \
-v $(PWD):/data \
-w /data \
-e AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
-e AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
anigeo/awscli s3 cp release/ $(S3_TARGET) --recursive --include "$(NAME)_$(VERSION)_*.tgz"
release: upload-release
gh-release checksums sha256
gh-release create sequenceiq/$(NAME) $(VERSION) $(GIT_BRANCH) v$(VERSION)
release-next-ver: deps
./release-next-ver.sh
generate-aws-json:
curl -L https://atlas.hashicorp.com/api/v1/artifacts/sequenceiq/cbd/amazon.image/search | jq .versions[0] > mkdocs_theme/providers/aws.json
generate-openstack-json:
curl -L https://atlas.hashicorp.com/api/v1/artifacts/sequenceiq/cbd/openstack.image/search | jq .versions[0] >
mkdocs_theme/providers/openstack.json
circleci:
rm ~/.gitconfig
clean:
rm -rf build release
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build release generate-aws-json help
.DEFAULT_GOAL := help