Skip to content

Commit

Permalink
release builder
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Sep 15, 2022
1 parent 46c9f12 commit 1d7ce44
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 25 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: publish release
on:
push:
tags:
- "*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19

- name: Build binaries
run: |
make all
ls builds/
- name: Release files
uses: softprops/action-gh-release@v1
with:
name: "DailyGakki"
files: builds/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
/.idea/DailyGakki.iml
/.idea/*
/photos/*
assets.go
assets.go
/builds/*
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ FROM scratch

ENV TZ=Asia/Shanghai

COPY --from=builder /build/Gakki /Gakki
COPY --from=builder /build/DailyGakki /DailyGakki
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
WORKDIR /

ENTRYPOINT ["/Gakki"]
ENTRYPOINT ["/DailyGakki"]

# docker run -d --restart=always -e TOKEN="FXI" -e PHOTOS="/photos/" -e REVIEWER="123" \
# -v local/photo/path/:/photos -v database.json:/database.json
Expand Down
68 changes: 46 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
OS = darwin linux windows
ARCH = amd64
go-bindata:
@go get -u github.com/go-bindata/go-bindata/...
@go install github.com/go-bindata/go-bindata/...
ARCH = amd64 arm64


default:
git pull
@echo "Installing dependencies..."
make go-bindata
@echo "Build static files..."
make asset
@echo "Build current platform executable..."
go build -o DailyGakki .

static:
@echo "Installing dependencies..."
make go-bindata
@echo "Build static files..."
make asset
CGO_ENABLED=0 go build -a -ldflags '-s -w -extldflags "-static"' -o Gakki .

all:
git pull
make asset
@echo "Build all platform executables..."
@for o in $(OS) ; do \
for a in $(ARCH) ; do \
CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w" -o builds/DailyGakki-$$o-$$a .; \
done \
done
CGO_ENABLED=0 go build -a -ldflags '-s -w -extldflags "-static"' -o DailyGakki .


asset:
@echo "Installing dependencies and building static files......"
@go get -u github.com/go-bindata/go-bindata/...
@go install github.com/go-bindata/go-bindata/...
@~/go/bin/go-bindata -o assets.go images/...


Expand All @@ -44,3 +28,43 @@ clean:
@rm -f assets.go
@rm -f Gakki
@rm -f DailyGakki

all:
make clean
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 \
CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w" -o builds/DailyGakki-$$o-$$a.exe .; \
else \
CGO_ENABLED=0 GOOS=$$o GOARCH=$$a go build -ldflags="-s -w" -o builds/DailyGakki-$$o-$$a .; \
fi; \
done \
done

@make universal
@make checksum


checksum: builds/*
@echo "Generating checksums..."
if [ "$(shell uname)" = "Darwin" ]; then \
shasum -a 256 $^ >> builds/checksum-sha256sum.txt ;\
else \
sha256sum $^ >> builds/checksum-sha256sum.txt; \
fi


universal:
@echo "Building macOS universal binary..."
docker run --rm -v $(shell pwd)/builds:/app/ bennythink/lipo-linux -create -output \
DailyGakki-darwin-universal \
DailyGakki-darwin-amd64 DailyGakki-darwin-arm64

file builds/DailyGakki-darwin-universal

release:
git tag $(git rev-parse --short HEAD)
git push --tags

0 comments on commit 1d7ce44

Please sign in to comment.