Files
YYeTsBot/Makefile

81 lines
2.2 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)
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/...
cd yyetsweb/templates;~/go/bin/go-bindata -o assets.go resource.html index.html search.html js/... css/... fonts/... img/...
mv yyetsweb/templates/assets.go yyetsweb/assets.go
all:
make clean
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 \
cd $(WEB);CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w" -o builds/yyetsweb-$$o-$$a.exe .; \
else \
cd $(WEB);CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w" -o builds/yyetsweb-$$o-$$a .; \
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