forked from linkerd/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
159 lines (129 loc) · 4.48 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
export PROJECT ?= linkerd-site
RELEASE_URL = https://github.com/linkerd/linkerd2/releases
# Version values will be replaced by `get-versions` target.
export L5D2_STABLE_VERSION ?= "stable-X.X.X"
export L5D2_EDGE_VERSION ?= "edge-X.X.X"
GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
GIT_HASH = $(shell git log --pretty=format:'%h' -n 1)
define upload_public
gsutil -m rsync \
-d -r -c $(if $(DRY_RUN),-n,) \
tmp/$(1)/public gs://$(2)
endef
HAS_GSUTIL := $(shell command -v gsutil;)
HAS_FLARECTL := $(shell command -v flarectl;)
HAS_HUGO := $(shell command -v hugo;)
HAS_HTMLTEST := $(shell command -v htmltest;)
HAS_MDLINT := $(shell command -v markdownlint;)
.PHONY: publish
publish: get-versions build-linkerd.io deploy
@# Publish a new version of the sites
.PHONY: get-versions
get-versions:
@# Update the version for the %* site
@. ./bin/export-channel-versions; \
$(MAKE) replace-env-L5D2_STABLE_VERSION replace-env-L5D2_EDGE_VERSION
deploy-%: tmp/%/public
@# Upload a site to the correct bucket.
@# Options:
@#
@# DRY_RUN :: ${DRY_RUN}
$(call upload_public,$*,$*)
nocache-%:
gsutil -m setmeta -h "Cache-Control:no-cache,max-age=0" -r gs://$*/
deploy: deploy-linkerd.io deploy-run.linkerd.io deploy-versioncheck.linkerd.io nocache-run.linkerd.io nocache-versioncheck.linkerd.io
@# Deploy l5d2 related sites
tmp:
mkdir -p tmp
tmp/%:
@printf "Missing tmp/$*. Run\n\n\tmake tmp-sites\n\n"; exit 1
tmp/%/public:
@printf "Missing tmp/$*/public. Run:\n\n\tmake build-$*\n\n"; exit 1
.PHONY: tmp-sites
tmp-sites: clean tmp
cp -R *linkerd.io tmp/
.PHONY: lint
lint:
@# lint the markdown for linkerd.io
ifndef HAS_MDLINT
@printf "Install markdownlint first, run npm install -g markdownlint-cli\n"; exit 1
endif
markdownlint -c linkerd.io/.markdownlint.yaml \
-i linkerd.io/content/blog \
-i linkerd.io/content/dashboard \
linkerd.io/content
markdownlint -c linkerd.io/.markdownlint.blog.yaml \
linkerd.io/content/blog \
linkerd.io/content/dashboard
.PHONY: check
check: build-linkerd.io
@# Check linkerd.io for valid links and standards
ifndef HAS_HTMLTEST
@printf "Install htmltest first. curl --proto '=https' --tlsv1.2 -sSfL https://htmltest.wjdp.uk | bash\n"; exit 1
endif
cd tmp/linkerd.io && htmltest
.PHONY: shellcheck
shellcheck:
@# lint the install scripts
shellcheck run.linkerd.io/public/install* \
api.linkerd.io/build \
linkerd.io/build \
linkerd.io/release-next-version
.PHONY: test-ci
test-ci:
@# Test CI configuration without constant commits to config.yml
ifndef CIRCLE_TOKEN
@printf "Create a personal CircleCI token first (CIRCLE_TOKEN). See https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token\n"; exit 1
endif
curl --user $(CIRCLE_TOKEN): \
--request POST \
--form revision=$(GIT_HASH) \
--form [email protected]/config.yml \
--form notify=false \
https://circleci.com/api/v1.1/project/github/linkerd/website/tree/$(GIT_BRANCH)
serve-%: build-%
@# Serve the built files locally
cd tmp/$*/public \
&& python3 -m http.server 9999
.PHONY: serve-api.linkerd.io
serve-api.linkerd.io: build-api.linkerd.io
@# Serve the built files locally
cd api.linkerd.io/public \
&& python3 -m http.server 9999
.PHONY: build-linkerd.io
build-linkerd.io: build-release-matrix get-versions tmp/linkerd.io
@# Build linkerd.io
ifndef HAS_HUGO
@printf "Install hugo first. For OSX: brew install hugo\n"; exit 1
endif
cd tmp/linkerd.io && ./build
.PHONY: build-api.linkerd.io
build-api.linkerd.io:
@# Build api.linkerd.io
cd api.linkerd.io && ./build
.PHONY: build-%
build-%: get-versions
@# Build *.linkerd.io
.PHONY: replace-env-%
replace-env-%: has-env-% tmp-sites
@# Replace vars in files from the environment.
@grep -rnl '$*' tmp >/dev/null || \
( \
printf "There are no instances of $*, maybe you've already updated them?\n" && \
exit 1 \
)
for fname in $$(grep -rnl '$*' tmp); do \
sed 's/$*/$($*)/g' < $$fname > /tmp/__sed && mv /tmp/__sed $$fname; \
done
.PHONY: build-release-matrix
build-release-matrix:
@# Build release matrix
./bin/generate_release_matrix.py --release_type=stable --format=json > linkerd.io/data/releases/release_matrix.json
./bin/generate_release_matrix.py --release_type=stable --format=yaml > linkerd.io/content/releases/release_matrix.yaml
cp linkerd.io/data/releases/release_matrix.json linkerd.io/content/releases/release_matrix.json
.PHONY: has-env-%
has-env-%:
@if [ ! $${$*:-} ]; then printf "You must define: $*\n" && exit 1; fi
.PHONY: clean
clean:
rm -rf tmp