-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
69 lines (50 loc) · 2.02 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
all: build
APP_GIT := AnnonaOrg/annona_core
APP := annona_core
DOCKER_IMAGE := annona/annona_core
VERSION := $(shell git describe --tags --abbrev=0)
COMMIT := $(shell git rev-parse --short HEAD)
BUILD_DATE := `date +%FT%T%z`
COMMIT_ID := `git log |head -n 1| awk '{print $2;}'`
AUTHOR := `git log |head -n 3| grep Author| awk '{print $2;}'`
BRANCH_NAME := `git branch | awk '/\*/ { print $2; }'`
LD_FLAGS := "-s -w -buildid="
DEB_IMG_ARCH := amd64
linux-amd64:
@ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags=$(LD_FLAGS) -o ./cmd/$(APP)/$(APP)-$@ ./cmd/$(APP)/
darwin-amd64:
@ CGO_ENABLED=1 CC=clang GOOS=darwin GOARCH=amd64 go build -buildmode=pie -ldflags=$(LD_FLAGS) -o ./cmd/$(APP)/$(APP)-$@ ./cmd/$(APP)/
windows:
@CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -buildmode=pie -ldflags=$(LD_FLAGS) -o ./cmd/$(APP)/$(APP).exe ./cmd/$(APP)/
build: darwin-amd64 windows
run:
@ LOG_DATE_TIME=1 DEBUG=1 RUN_MIGRATIONS=1 go run ./cmd/$(APP)/
clean:
@ rm -f db.kns $(APP)-* $(APP) $(APP)*.rpm $(APP)*.deb ./cmd/$(APP)/$(APP)*.exe ./cmd/$(APP)/$(APP)-* ./cmd/$(APP)/*.kns ./cmd/$(APP)/$(APP)
@ rm -rf ./conf ./log ./upload
@ rm -rf ./cmd/$(APP)/conf ./cmd/$(APP)/log ./cmd/$(APP)/upload
@ rm -rf ./cmd/$(APP)/*.lock
gitinit:
git init
git add .
git commit -m "第一次提交"
git remote add github [email protected]:$(APP_GIT).git
git push -u github main
git tag "v0.0.1"
git push --tags -u github main
gitpush:
git push -u github main
git push --tags -u github main
docker-image:
curl -o cacert.pem https://curl.se/ca/cacert.pem
docker build -t $(DOCKER_IMAGE):$(VERSION) -t $(DOCKER_IMAGE):latest -f Dockerfile . && \
docker push $(DOCKER_IMAGE):latest && \
docker push $(DOCKER_IMAGE):$(VERSION)
docker-images:
curl -o cacert.pem https://curl.se/ca/cacert.pem
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--file Dockerfile \
--tag $(DOCKER_IMAGE):latest \
--tag $(DOCKER_IMAGE):$(VERSION) \
--push .