-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTaskfile.yml
106 lines (104 loc) · 3.4 KB
/
Taskfile.yml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
version: '3'
# 全局变量
vars:
APP: test
SOURCE: test/test.go
# 0 || 1
CGO_ENABLED: 0
VERSION: 0.0.1
BUILDER:
sh: whoami
BUILD_DATE:
sh: date '+%F'
BUILD_TIME:
sh: date '+%FT%T %A %Z'
tasks:
default:
cmds:
- task: prepare
# - task: build-serial
- task: build-parallel
prepare:
cmds:
- go mod tidy
# 串行
build-serial:
cmds:
- task: windows-386
- task: windows-amd64
- task: darwin-arm64
- task: linux-amd64
- task: linux-amd64-noavx
- task: linux-arm64
- task: linux-mips64
- task: linux-mips64le
- task: linux-loong64
# 并行
build-parallel:
deps:
- task: windows-386
- task: windows-amd64
- task: darwin-arm64
- task: linux-amd64
- task: linux-amd64-noavx
- task: linux-arm64
- task: linux-mips64
- task: linux-mips64le
- task: linux-loong64
windows-386:
cmds:
- task: build
vars: { OS: windows, ARCH: 386, CC: i686-w64-mingw32-gcc, CXX: i686-w64-mingw32-g++, TAGS: go_json, UPX: true }
windows-amd64-noavx:
cmds:
- task: build
vars: { OS: windows, ARCH: amd64, CC: x86_64-w64-mingw32-gcc, CXX: x86_64-w64-mingw32-g++, TAGS: go_json, UPX: true }
windows-amd64:
cmds:
- task: build
vars: { OS: windows, ARCH: amd64, CC: x86_64-w64-mingw32-gcc, CXX: x86_64-w64-mingw32-g++, TAGS: sonic avx, UPX: true }
darwin-arm64:
cmds:
- task: build
vars: { OS: darwin, ARCH: arm64, TAGS: sonic, UPX: false }
linux-amd64:
cmds:
- task: build
vars: { OS: linux, ARCH: amd64, CC: x86_64-linux-musl-gcc, CXX: x86_64-linux-musl-g++, TAGS: sonic avx, UPX: true }
linux-amd64-noavx:
cmds:
- task: build
vars: { OS: linux, ARCH: amd64, CC: x86_64-linux-musl-gcc, CXX: x86_64-linux-musl-g++, TAGS: go_json, UPX: true }
linux-arm64:
cmds:
- task: build
vars: { OS: linux, ARCH: arm64, CC: x86_64-linux-musl-gcc, CXX: x86_64-linux-musl-g++, TAGS: go_json, UPX: true }
linux-mips64:
cmds:
- task: build
vars: { OS: linux, ARCH: mips64, CC: x86_64-linux-musl-gcc, CXX: x86_64-linux-musl-g++, TAGS: go_json, UPX: false }
linux-mips64le:
cmds:
- task: build
vars: { OS: linux, ARCH: mips64le, CC: x86_64-linux-musl-gcc, CXX: x86_64-linux-musl-g++, TAGS: go_json, UPX: false }
linux-loong64:
cmds:
- task: build
vars: { OS: linux, ARCH: loong64, CC: x86_64-linux-musl-gcc, CXX: x86_64-linux-musl-g++, TAGS: go_json, UPX: false }
build:
vars:
OS: '{{default "UNKNOWN" .OS}}'
ARCH: '{{default "UNKNOWN" .ARCH}}'
CC: '{{default "cc" .CC}}'
CXX: '{{default "c++" .CXX}}'
EXT: '{{if eq .OS "windows"}}.exe{{end}}'
TAGS: '{{default "" .TAGS}}'
UPX: '{{default "false" .UPX}}'
NOAVX: '{{if and (eq .ARCH "amd64") (ne .TAGS "sonic avx")}}_noavx{{end}}'
NAME: '{{.APP}}_{{.VERSION}}_{{.OS}}_{{.ARCH}}{{.NOAVX}}{{.EXT}}'
TARGET: '{{.NAME}}'
cmds:
- echo {{.TARGET}}
- rm -rf {{.TARGET}} # 文件可以不存在
- CGO_ENABLED={{.CGO_ENABLED}} CC={{.CC}} CXX={{.CXX}} GOOS={{.OS}} GOARCH={{.ARCH}} go build -o {{.TARGET}} -ldflags "-X 'main.Version={{.VERSION}}' -X 'main.Builder={{.BUILDER}}' -X 'main.BuildTime={{.BUILD_TIME}}' -s -w" -tags="{{.TAGS}}" {{.SOURCE}}
- if [ {{.UPX}} == "true" ]; then upx -9 {{.TARGET}}; fi