forked from hortonworks/cloudbreak-deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (130 loc) · 5.95 KB
/
Makefile
File metadata and controls
165 lines (130 loc) · 5.95 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
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
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/
# 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_CAAS_MOCK/ s/DOCKER_TAG_CAAS_MOCK .*/DOCKER_TAG_CAAS_MOCK $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_PERISCOPE/ s/DOCKER_TAG_PERISCOPE .*/DOCKER_TAG_PERISCOPE $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_DATALAKE/ s/DOCKER_TAG_DATALAKE .*/DOCKER_TAG_DATALAKE $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_REDBEAMS/ s/DOCKER_TAG_REDBEAMS .*/DOCKER_TAG_REDBEAMS $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_ENVIRONMENT/ s/DOCKER_TAG_ENVIRONMENT .*/DOCKER_TAG_ENVIRONMENT $(CB_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_FREEIPA/ s/DOCKER_TAG_FREEIPA .*/DOCKER_TAG_FREEIPA $(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
update-container-versions-cdpcp:
sed -i "0,/DOCKER_TAG_IDBMMS/ s/DOCKER_TAG_IDBMMS .*/DOCKER_TAG_IDBMMS $(CDPCP_VERSION)/" include/cloudbreak.bash
sed -i "0,/DOCKER_TAG_ENVIRONMENTS2_API/ s/DOCKER_TAG_ENVIRONMENTS2_API .*/DOCKER_TAG_ENVIRONMENTS2_API $(CDPCP_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
push-container-versions-cdpcp: update-container-versions-cdpcp
git add include/cloudbreak.bash
git commit -m "Updated CDPCP container versions to $(CDPCP_VERSION)"
git push origin HEAD:$(GIT_BRANCH)
build: bindata ## Creates linux an osx binaries in "build/$OS"
go test
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 test
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 templates .deps/bin
go test
go build -ldflags $(FLAGS) -o /usr/local/bin/$(BINARYNAME)
bindata: deps-bindata
go-bindata include templates .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/go-bindata/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
prepare-release:
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 hortonworks/$(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/hortonworks/cbd/amazon.image/search | jq .versions[0] > mkdocs_theme/providers/aws.json
generate-openstack-json:
curl -L https://atlas.hashicorp.com/api/v1/artifacts/hortonworks/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