Files
YYeTsBot/Makefile

92 lines
2.5 KiB
Makefile
Raw Normal View History

2022-10-06 20:37:14 +08:00
OS = darwin linux windows
ARCH = amd64 arm64
WEB := $(shell cd yyetsweb;pwd)
2022-10-08 18:02:25 +08:00
DATE:=$(shell date +"%Y-%m-%d %H:%M:%S")
2021-07-12 18:11:41 +08:00
update:
git pull
git submodule update --remote
2021-07-12 18:11:41 +08:00
2022-10-06 20:37:14 +08:00
docker-dev:
2021-07-12 18:11:41 +08:00
make update
docker build --build-arg env=dev -t bennythink/yyetsbot .
docker-compose up -d
2022-10-06 20:37:14 +08:00
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:
2022-10-06 20:37:14 +08:00
docker rmi bennythink/yyetsbot:latest || true
2021-07-12 18:11:41 +08:00
rm -rf YYeTsFE/build
rm -rf YYeTsFE/dist
2022-10-06 20:37:14 +08:00
@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 .;
2022-10-06 20:37:14 +08:00
asset:
cd $(WEB);go get -u github.com/go-bindata/go-bindata/... ;go install github.com/go-bindata/go-bindata/...
2022-10-08 18:02:25 +08:00
cd $(WEB)/templates;~/go/bin/go-bindata -o assets.go ./...
2022-10-06 20:37:14 +08:00
mv yyetsweb/templates/assets.go yyetsweb/assets.go
2022-10-08 18:02:25 +08:00
frontend:
cd YYeTsFE; yarn && yarn run release
cp -R YYeTsFE/build/* yyetsweb/templates/
2022-10-06 20:37:14 +08:00
all:
make clean
2022-10-08 18:02:25 +08:00
make frontend
2022-10-06 20:37:14 +08:00
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 \
2022-10-08 18:02:25 +08:00
cd $(WEB);CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w -X 'main.buildTime=$(DATE)'" -o builds/yyetsweb-$$o-$$a.exe .; \
2022-10-06 20:37:14 +08:00
else \
2022-10-08 18:02:25 +08:00
cd $(WEB);CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w -X 'main.buildTime=$(DATE)'" -o builds/yyetsweb-$$o-$$a .; \
2022-10-06 20:37:14 +08:00
fi; \
done \
done
2022-10-06 20:37:14 +08:00
@make universal
@make checksum
2021-07-12 18:11:41 +08:00
2022-10-06 20:37:14 +08:00
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
2023-02-13 19:41:57 +01:00
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'