Skip to content

Commit

Permalink
ci: add makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Nov 23, 2024
1 parent 5204545 commit ac5a5a3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,9 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: latest
- name: build frontend
working-directory: frontend
run: |
npm install
npm run build
- name: setup go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: compile
run: |
GOOS=linux GOARCH=amd64 go build -ldflags '-w -s' -o cacao-linux-amd64
GOOS=linux GOARCH=arm64 go build -ldflags '-w -s' -o cacao-linux-arm64
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags '-w -s' -o cacao-linux-armv7
GOOS=freebsd GOARCH=amd64 go build -ldflags '-w -s' -o cacao-freebsd-amd64
env:
CGO_ENABLED: 0
run: make all
13 changes: 1 addition & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,12 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: latest
- name: build frontend
working-directory: frontend
run: |
npm install
npm run build
- name: setup go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: compile
run: |
GOOS=linux GOARCH=amd64 go build -ldflags '-w -s' -o cacao-linux-amd64
GOOS=linux GOARCH=arm64 go build -ldflags '-w -s' -o cacao-linux-arm64
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags '-w -s' -o cacao-linux-armv7
GOOS=freebsd GOARCH=amd64 go build -ldflags '-w -s' -o cacao-freebsd-amd64
env:
CGO_ENABLED: 0
run: make all
- name: artifact
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cacao
cacao-*
sqlite.db
cookie
*.mmdb
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
GOBUILD = env CGO_ENABLED=0 go build -trimpath -ldflags '-w -s' -o cacao

default: cacao

all: linux-amd64 linux-arm64 linux-armv7 freebsd-amd64

frontend:
cd frontend && npm run build || (npm install && npm run build)

cacao: frontend
$(GOBUILD)

linux-amd64: frontend
GOOS=linux GOARCH=amd64 $(GOBUILD)-$@

linux-arm64: frontend
GOOS=linux GOARCH=arm64 $(GOBUILD)-$@

linux-armv7: frontend
GOOS=linux GOARCH=arm GOARM=7 $(GOBUILD)-$@

freebsd-amd64: frontend
GOOS=freebsd GOARCH=amd64 $(GOBUILD)-$@

.PHONY: default all frontend cacao linux-amd64 linux-arm64 linux-armv7 freebsd-amd64

0 comments on commit ac5a5a3

Please sign in to comment.