-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Makefile
92 lines (73 loc) · 2.53 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
OS = darwin linux windows
ARCH = amd64 arm64
WEB := $(shell cd yyetsweb;pwd)
DATE:=$(shell date +"%Y-%m-%d %H:%M:%S")
update:
git pull
git submodule update --remote
docker-dev:
make update
docker build --build-arg env=dev -t bennythink/yyetsbot .
docker-compose up -d
docker:
# production configuration
cp .env YYeTsFE/.env
# docker buildx create --use --name mybuilder
docker buildx build --platform=linux/amd64,linux/arm64 -t bennythink/yyetsbot . --push
clean:
docker rmi bennythink/yyetsbot:latest || true
rm -rf YYeTsFE/build
rm -rf YYeTsFE/dist
@rm -rf yyetsweb/builds
@rm -f yyetsweb/assets.go
current:
echo "Installing dependencies..."
cd $(WEB);go get -u github.com/go-bindata/go-bindata/...
echo "Build static files..."
make asset
echo "Build current platform executable..."
cd $(WEB); go build .;
asset:
cd $(WEB);go get -u github.com/go-bindata/go-bindata/... ;go install github.com/go-bindata/go-bindata/...
cd $(WEB)/templates;~/go/bin/go-bindata -o assets.go ./...
mv yyetsweb/templates/assets.go yyetsweb/assets.go
frontend:
cd YYeTsFE; yarn && yarn run release
cp -R YYeTsFE/build/* yyetsweb/templates/
all:
make clean
make frontend
make asset
@echo "Build all platform executables..."
@for o in $(OS) ; do \
for a in $(ARCH) ; do \
echo "Building $$o-$$a..."; \
if [ "$$o" = "windows" ]; then \
cd $(WEB);CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w -X 'main.buildTime=$(DATE)'" -o builds/yyetsweb-$$o-$$a.exe .; \
else \
cd $(WEB);CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w -X 'main.buildTime=$(DATE)'" -o builds/yyetsweb-$$o-$$a .; \
fi; \
done \
done
@make universal
@make checksum
checksum: yyetsweb/builds/*
@echo "Generating checksums..."
if [ "$(shell uname)" = "Darwin" ]; then \
shasum -a 256 $^ >> $(WEB)/builds/checksum-sha256sum.txt ;\
else \
sha256sum $^ >> $(WEB)/builds/checksum-sha256sum.txt; \
fi
universal:
@echo "Building macOS universal binary..."
docker run --rm -v $(WEB)/builds:/app/ bennythink/lipo-linux -create -output \
yyetsweb-darwin-universal \
yyetsweb-darwin-amd64 yyetsweb-darwin-arm64
file $(WEB)/builds/yyetsweb-darwin-universal
release:
git tag $(shell git rev-parse --short HEAD)
git push --tags
ci-test:
docker run --rm bennythink/yyetsbot /bin/sh -c "cd /YYeTsBot/yyetsweb/tests;python -m unittest discover -p '*_test.py'"
test:
cd $(WEB)/tests;python -m unittest discover -p '*_test.py'