-
Notifications
You must be signed in to change notification settings - Fork 1
/
regenerate.sh
executable file
·38 lines (30 loc) · 1.2 KB
/
regenerate.sh
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
#!/bin/bash -e
# step0: check and install required dependencies
which git &> /dev/null || (echo "git not found...install" && exit)
which gofmt &> /dev/null || (echo "gofmt not found...exit" && exit)
which goimports &> /dev/null || (echo "goimports not found...install" && go get golang.org/x/tools/cmd/goimports)
which goi18n &> /dev/null || (echo "goi18n not found...install" && go get -u github.com/nicksnyder/go-i18n/v2/goi18n)
which bindata &> /dev/null || (echo "bindata not found...install" && go get -u github.com/hitzhangjie/codeblocks/bindata)
# step1: reformat the code
#gofmt -s -w .
#goimports -w -local github.com .
#step2: update the template version
echo "VERSION=${rev}" > install/VERSION
#step3: update the GoRPCVersion
rev=$(git rev-parse --short HEAD)
cat > config/version.go <<EOF
package config
var GORPCCliVersion string = "${rev}"
EOF
#step4: extract the message
goi18n extract -format json i18n/zh/message_zh.go
mv active.en.json install/active.zh.json
goi18n extract -format json i18n/en/message_en.go
mv active.en.json install/
#step5: update gorpc.pb.go
cd extension
go generate
cd -
#step6: compress the templates
rm -rf bindata
bindata -input install -output bindata/assets.go -gopkg bindata