-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
83 lines (71 loc) · 3.24 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
BUILD_ORG := talkincode
BUILD_VERSION := latest
BUILD_TIME := $(shell date "+%F %T")
BUILD_NAME := logsight
RELEASE_VERSION := v1.0.1
SOURCE := main.go
RELEASE_DIR := ./release
COMMIT_SHA1 := $(shell git show -s --format=%H )
COMMIT_DATE := $(shell git show -s --format=%cD )
COMMIT_USER := $(shell git show -s --format=%ce )
COMMIT_SUBJECT := $(shell git show -s --format=%s )
buildpre:
echo "BuildVersion=${BUILD_VERSION} ${RELEASE_VERSION} ${BUILD_TIME}" > assets/buildinfo.txt
echo "ReleaseVersion=${RELEASE_VERSION}" >> assets/buildinfo.txt
echo "BuildTime=${BUILD_TIME}" >> assets/buildinfo.txt
echo "BuildName=${BUILD_NAME}" >> assets/buildinfo.txt
echo "CommitID=${COMMIT_SHA1}" >> assets/buildinfo.txt
echo "CommitDate=${COMMIT_DATE}" >> assets/buildinfo.txt
echo "CommitUser=${COMMIT_USER}" >> assets/buildinfo.txt
echo "CommitSubject=${COMMIT_SUBJECT}" >> assets/buildinfo.txt
fastpub:
docker buildx build --platform=linux/amd64 --build-arg BTIME="$(shell date "+%F %T")" -t logsight .
docker tag logsight ${BUILD_ORG}/logsight:latest
docker push ${BUILD_ORG}/logsight:latest
fastpubm1:
make build
docker buildx build --platform=linux/amd64 --build-arg BTIME="$(shell date "+%F %T")" -t logsight . -f Dockerfile.local
docker tag logsight ${BUILD_ORG}/logsight:latest-amd64
docker push ${BUILD_ORG}/logsight:latest-amd64
make buildarm64
docker buildx build --platform=linux/arm64 --build-arg BTIME="$(shell date "+%F %T")" -t logsight . -f Dockerfile.local
docker tag logsight ${BUILD_ORG}/logsight:latest-arm64
docker push ${BUILD_ORG}/logsight:latest-arm64
docker manifest create ${BUILD_ORG}/logsight:latest ${BUILD_ORG}/logsight:latest-arm64 ${BUILD_ORG}/logsight:latest-amd64
# 标注不同架构镜像
docker manifest annotate ${BUILD_ORG}/logsight:latest ${BUILD_ORG}/logsight:latest-amd64 --os linux --arch amd64
docker manifest annotate ${BUILD_ORG}/logsight:latest ${BUILD_ORG}/logsight:latest-arm64 --os linux --arch arm64
# 推送镜像
docker manifest push ${BUILD_ORG}/logsight:latest
build:
test -d ./release || mkdir -p ./release
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w -extldflags "-static"' -o ./release/logsight main.go
upx ./release/logsight
buildarm64:
test -d ./release || mkdir -p ./release
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -ldflags '-s -w -extldflags "-static"' -o ./release/logsight main.go
upx ./release/logsight
syncdev:
make buildpre
@read -p "提示:同步操作尽量在完成一个完整功能特性后进行,请输入提交描述 (develop): " cimsg; \
git commit -am "$(shell date "+%F %T") : $${cimsg}"
# 切换主分支并更新
git checkout main
git pull origin main
# 切换开发分支变基合并提交
git checkout develop
git rebase -i main
# 切换回主分支并合并开发者分支,推送主分支到远程,方便其他开发者合并
git checkout main
git merge --no-ff develop
git push origin main
# 切换回自己的开发分支继续工作
git checkout develop
updev:
make buildpre
make build
scp ${RELEASE_DIR}/${BUILD_NAME} trdev-server:/tmp/logsight
ssh trdev-server "systemctl stop logsight && /tmp/logsight -install && systemctl start logsight"
swag:
swag fmt && swag init
.PHONY: clean build