-
Notifications
You must be signed in to change notification settings - Fork 346
/
Makefile.production
138 lines (102 loc) · 6.2 KB
/
Makefile.production
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
-include Makefile.passwords
RELEASE=$(shell git describe --long | sed 's@\([0-9.]\{1,\}\).*@\1@')
VERSION=$(shell git describe --long)
OGS_HASH=$(shell md5sum dist/ogs.min.js | awk '{print $$1}')
VENDOR_HASH=$(shell md5sum dist/vendor.min.js | awk '{print $$1}')
OGS_VERSION_HASH=$(VERSION)-$(OGS_HASH)
SLACK_WEBHOOK=$(shell cat ../ogs/.slack-webhook)
stats:
npm run webpack -- --mode production --optimization-minimize --devtool=source-map --output-filename 'ogs.min.js' --json > webpack-stats.json
cat webpack-stats.json
todo:
cd src; grep -r 'TODO: Implement' views components lib | grep -v gen.py | sort | grep --color -E '^[^:]*:'
cd src; grep -r 'TODO: Implement' views components lib | grep -v gen.py | wc -l
todo-all:
cd src; grep -r TODO views components lib | grep --color -E '^[^:]*:'
cd src; grep -r TODO views components lib | wc -l
LANGUAGE_VERSION=`md5sum i18n/locale/*.js | sort | md5sum | awk '{print $$1}'`
SUPPORTED_LANGUAGES=`python -c 'import json; print(json.dumps(json.loads(open("i18n/languages.json", "r").read())))'`
GOBAN_VERSION=`python -c 'import json; print(json.loads(open("package.json", "r").read())["devDependencies"]["goban"][1:])'`
BASE_INDEX_HEADERS=-H "Content-Type: text/plain" \
-H "X-OGS-Index-Release: $(RELEASE)" \
-H "X-OGS-Index-Version: $(VERSION)" \
-H "X-OGS-Supported-Languages: $(SUPPORTED_LANGUAGES)" \
-H "X-OGS-Goban-Js: https://cdn.online-go.com/goban/$(GOBAN_VERSION)/goban.min.js" \
-H "X-OGS-Language-Version: $(LANGUAGE_VERSION)" \
DEV_INDEX_HEADERS=$(BASE_INDEX_HEADERS) -H "X-OGS-Index-Auth: $(DEV_INDEX_AUTH)"
BETA_INDEX_HEADERS=$(BASE_INDEX_HEADERS) -H "X-OGS-Index-Auth: $(BETA_INDEX_AUTH)"
PROD_INDEX_HEADERS=$(BASE_INDEX_HEADERS) -H "X-OGS-Index-Auth: $(PROD_INDEX_AUTH)"
#dev-put: push-cdn
dev-put:
OGS_VERSION_HASH=$(OGS_VERSION_HASH) VENDOR_HASH=$(VENDOR_HASH) npm run minify-index --silent | curl -X PUT $(DEV_INDEX_HEADERS) -d @- http://localhost:1080/_index
dev-del:
curl -X DELETE $(BETA_INDEX_HEADERS) http://localhost:1080/_index
beta-put: sync-translations create-unified-pot audit-translations jsonify-po-files push-cdn upload-sentry-source-maps
OGS_VERSION_HASH=$(OGS_VERSION_HASH) VENDOR_HASH=$(VENDOR_HASH) npm run minify-index --silent | curl -X PUT $(BETA_INDEX_HEADERS) -d @- https://beta.online-go.com/_index
make beta-notify-slack
live-put: confirm-go-live push-cdn
OGS_VERSION_HASH=$(OGS_VERSION_HASH) VENDOR_HASH=$(VENDOR_HASH) npm run minify-index --silent | curl -X PUT $(PROD_INDEX_HEADERS) -d @- https://online-go.com/_index
make live-notify-slack
live-maint: confirm-go-live
curl -X PUT $(PROD_INDEX_HEADERS) -T src/maint.html https://online-go.com/_index
beta-notify-slack:
MSG=`git log -1 --pretty="%B" | sed s/\"//g | sed s/\'//g `; \
VERSION=`git describe --long`; \
echo $$VERSION $$MSG; \
curl -X POST -H 'Content-type: application/json' --data '{"text":"'"[BETA UI] $$VERSION $$MSG"'"}' $(SLACK_WEBHOOK)
live-notify-slack:
MSG=`git log -1 --pretty="%B" | sed s/\"//g | sed s/\'//g `; \
VERSION=`git describe --long`; \
echo $$VERSION $$MSG; \
curl -X POST -H 'Content-type: application/json' --data '{"text":"'"[PRODUCTION UI] $$VERSION $$MSG"'"}' $(SLACK_WEBHOOK)
confirm-go-live:
@read -p "Go live? " yesno; \
test $$yesno == 'yes';
push: push-cdn
push-cdn: prepare-cdn-files
gsutil -m rsync -r deployment-staging-area/$(RELEASE) gs://ogs-site-files/$(RELEASE)/
gsutil -m setmeta -h "Content-Type:audio/webm" 'gs://ogs-site-files/$(RELEASE)/sound/*.webm'
sync-translations:
cd i18n/build/; ssh pootle@pootle "bash -c 'cd online-go.com/i18n/build; tar jcf - *'" | tar jxf -
cd i18n/locale/; ssh pootle@pootle "bash -c 'cd online-go.com/i18n/locale; tar jcf - *'" | tar jxf -
create-unified-pot:
# This is run on the pootle server and here, the pootle server does most of the work,
# this invocation extracts strings that need to be translated by LLMs
cd i18n; node create-unified-pot.js llm-translation-extraction
audit-translations:
cd i18n; node audit-translations.js
jsonify-po-files:
cd i18n; node jsonify-po-files.js
prepare-cdn-files: purge-cdn-files dist/ogs.min.js dist/vendor.min.js dist/ogs.$(VERSION).css
echo "Language version: $(LANGUAGE_VERSION)"
mkdir -p deployment-staging-area/$(RELEASE)/
mkdir -p deployment-staging-area/$(RELEASE)/locale
cat dist/ogs.min.js | sed 's/ogs.min.js.map/ogs.$(OGS_VERSION_HASH).js.map/' > deployment-staging-area/$(RELEASE)/ogs.$(OGS_VERSION_HASH).js
cat dist/vendor.min.js | sed 's/vendor.min.js.map/vendor.$(VENDOR_HASH).js.map/' > deployment-staging-area/$(RELEASE)/vendor.$(VENDOR_HASH).js
cp -p dist/ogs.min.js.map deployment-staging-area/$(RELEASE)/ogs.$(OGS_VERSION_HASH).js.map
cp -p dist/vendor.min.js.map deployment-staging-area/$(RELEASE)/vendor.$(VENDOR_HASH).js.map
cp -p dist/ogs.$(VERSION).css deployment-staging-area/$(RELEASE)/
cp -p dist/ogs.$(VERSION).css.map deployment-staging-area/$(RELEASE)/
cp -Rp assets/img deployment-staging-area/$(RELEASE)/
cp -Rp assets/sound deployment-staging-area/$(RELEASE)/
ls i18n/locale/*.js | sed 's@i18n/locale/\([^\.]\+\).js@\1@' | xargs -n1 -I {} cp i18n/locale/{}.js deployment-staging-area/$(RELEASE)/locale/{}.$(LANGUAGE_VERSION).js
# cleanup
find deployment-staging-area/ | grep \\.swp$$ | xargs rm -f
find deployment-staging-area/ | grep "~" | xargs rm -f
find deployment-staging-area/ | grep /backup/ | xargs rm -f
find deployment-staging-area/ | grep \\.bak$$ | xargs rm -f
find deployment-staging-area/ | grep \\.xcf$$ | xargs rm -f
find deployment-staging-area/ | grep \\.dat$$ | xargs rm -f
upload-sentry-source-maps:
sentry-cli releases --org online-gocom --project online-gocom new $(VERSION)
sentry-cli releases --org online-gocom --project online-gocom files $(VERSION) upload-sourcemaps --ignore locale deployment-staging-area/$(RELEASE)/
sentry-cli releases --org online-gocom --project online-gocom finalize $(VERSION)
purge-cdn-files:
rm -Rf deployment-staging-area
dist/ogs.min.js: dist/ogs.js
npm run webpack -- --mode=production --optimization-minimize --devtool=source-map
dist/vendor.min.js:
npm run webpack -- --mode=production --optimization-minimize --devtool=source-map
dist/ogs.$(VERSION).css:
npm run gulp min_styl
.PHONY: dev stats todo update install default min server dist push-cdn sync-translations