-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
121 lines (93 loc) · 4.97 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
# Makefile for Ruby driver docs
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
USER=$(shell whoami)
STAGING_URL="https://docs-mongodborg-staging.corp.mongodb.com"
PRODUCTION_URL="https://docs.mongodb.com"
STAGING_BUCKET=docs-mongodb-org-prd-staging
PRODUCTION_BUCKET=docs-mongodb-org-prd
SEARCH_INDEX_BUCKET=docs-search-indexes-test
PROJECT=ruby-driver
PREFIX=ruby-driver
DOTCOM_STAGING_URL="https://mongodbcom-cdn.website.staging.corp.mongodb.com"
DOTCOM_STAGING_BUCKET=docs-mongodb-org-dotcomstg
DOTCOM_PRODUCTION_URL="https://mongodb.com"
DOTCOM_PRODUCTION_BUCKET=docs-mongodb-org-dotcomprd
DOTCOM_PREFIX=docs/ruby-driver
DOTCOM_STGPREFIX=docs/ruby-driver
TARGET_DIR=source-${GIT_BRANCH}
SOURCE_FILE_DIR=build/ruby-driver-${GIT_BRANCH}
# Parse our published-branches configuration file to get the name of
# the current "stable" branch. This is weird and dumb, yes.
STABLE_BRANCH=`grep 'manual' build/docs-tools/data/${PROJECT}-published-branches.yaml | cut -d ':' -f 2 | grep -Eo '[0-9a-z.]+'`
.PHONY: help stage fake-deploy deploy deploy-search-index api-docs check-redirects publish-build-only publish migrate clean
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo
@echo 'Variables'
@printf " \033[36m%-18s\033[0m %s\n" 'ARGS' 'Arguments to pass to mut-publish'
html: migrate ## Builds this branch's HTML under build/<branch>/html
giza make html
publish-build-only: ## Builds this branch's publishable HTML and other artifacts under build/public
giza make publish
if [ ${GIT_BRANCH} = master ]; then mut-redirects config/redirects -o build/public/.htaccess; fi
publish: migrate ## Build publishable artifacts, and also migrates assets
giza make publish
@echo "Making api directory in /build/public/${GIT_BRANCH}"
if [ -d build/public/${GIT_BRANCH}/api ]; then rm -rf build/public/${GIT_BRANCH}/api ; fi;
mkdir build/public/${GIT_BRANCH}/api
yard doc ${SOURCE_FILE_DIR} \
--exclude ${SOURCE_FILE_DIR}/.evergreen \
--exclude ${SOURCE_FILE_DIR}/.mod \
--exclude ${SOURCE_FILE_DIR}/examples \
--exclude ${SOURCE_FILE_DIR}/profile \
--exclude ${SOURCE_FILE_DIR}/release \
--exclude ${SOURCE_FILE_DIR}/spec \
--readme ${SOURCE_FILE_DIR}/README.md -o build/public/${GIT_BRANCH}/api/
if [ ${GIT_BRANCH} = master ]; then mut-redirects config/redirects -o build/public/.htaccess; fi
stage: ## Host online for review
mut-publish build/${GIT_BRANCH}/html ${DOTCOM_STAGING_BUCKET} --prefix=${DOTCOM_STGPREFIX} --stage ${ARGS}
@echo "Hosted at ${DOTCOM_STAGING_URL}/${DOTCOM_STGPREFIX}/${USER}/${GIT_BRANCH}/index.html"
fake-deploy: build/public/${GIT_BRANCH} ## Create a fake deployment in the staging bucket
mut-publish build/public/ ${DOTCOM_STAGING_BUCKET} --prefix=${DOTCOM_STGPREFIX} --deploy --verbose --redirects build/public/.htaccess ${ARGS}
@echo "Hosted at ${DOTCOM_STAGING_BUCKET}/${DOTCOM_STGPREFIX}/${GIT_BRANCH}/index.html"
deploy: build/public/${GIT_BRANCH} ## Deploy to the production bucket
mut-publish build/public/ ${DOTCOM_PRODUCTION_BUCKET} --prefix=${DOTCOM_PREFIX} --deploy --redirects build/public/.htaccess ${ARGS}
@echo "Hosted at ${DOTCOM_PRODUCTION_URL}/${DOTCOM_PREFIX}/${GIT_BRANCH}"
$(MAKE) deploy-search-index
deploy-search-index: ## Update the search index for this branch
@echo "Building search index"
if [ ${STABLE_BRANCH} = ${GIT_BRANCH} ]; then \
mut-index upload build/public/${GIT_BRANCH} -o docs-ruby-${GIT_BRANCH}.json -u ${PRODUCTION_URL}/${PROJECT}/${GIT_BRANCH} -b ${SEARCH_INDEX_BUCKET} -p search-indexes/prd -g -s; \
else \
mut-index upload build/public/${GIT_BRANCH} -o docs-ruby-${GIT_BRANCH}.json -u ${PRODUCTION_URL}/${PROJECT}/${GIT_BRANCH} -b ${SEARCH_INDEX_BUCKET} -p search-indexes/prd -s; \
fi
# in case you want to just generate the api-docs
# generate the api docs
# you must install yard
# generate the api docs from the ruby driver project and output to the build dir
api-docs:
@echo "Making api directory in /build/public/${GIT_BRANCH}"
if [ -d build/public/${GIT_BRANCH}/api ]; then rm -rf build/public/${GIT_BRANCH}/api ; fi;
mkdir build/public/${GIT_BRANCH}/api
yard doc ${SOURCE_FILE_DIR} \
--exclude ${SOURCE_FILE_DIR}/.evergreen \
--exclude ${SOURCE_FILE_DIR}/.mod \
--exclude ${SOURCE_FILE_DIR}/examples \
--exclude ${SOURCE_FILE_DIR}/profile \
--exclude ${SOURCE_FILE_DIR}/release \
--exclude ${SOURCE_FILE_DIR}/spec \
--readme ${SOURCE_FILE_DIR}/README.md -o build/public/${GIT_BRANCH}/api/
migrate: get-assets
@echo "Making target source directory -- doing this explicitly instead of via cp"
if [ -d ${TARGET_DIR} ]; then rm -rf ${TARGET_DIR} ; fi;
mkdir ${TARGET_DIR}
@echo "Copying over bson docs files"
cp -R build/bson-ruby/docs/* ${TARGET_DIR}
@echo "Deleting symlink ftw..."
rm ${TARGET_DIR}/index.txt
@echo "Copying over ruby-driver docs files"
cp -R build/ruby-driver-${GIT_BRANCH}/docs/* ${TARGET_DIR}
get-assets:
giza generate assets
clean:
rm -rf build giza.log source-master