forked from crra/mp3binder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
executable file
·155 lines (141 loc) · 3.7 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
version: "3"
dotenv: [".env"]
vars:
FOLDER_DIST: "dist"
REALM: "mp3binder"
MP3BINDER_NAME: mp3binder
MP3BINDER_MAIN: "./cmd/tui"
# used as version
GIT_COMMIT:
sh: git describe --tags --always | sed 's/-/+/' | sed 's/^v//'
tasks:
setup:
desc: Install required (go) tools
cmds:
- $GO install golang.org/x/tools/cmd/stringer
clean:
desc: Cleans temp files and folders
cmds:
- rm -rf {{.FOLDER_DIST}}
stringer:
cmds:
- $GO generate ./...
build-all:
desc: Build the binaries for multiple architectures.
deps:
- clean
- test
cmds:
# macOS intel
- task: build-for
vars:
{
NAME: "{{.MP3BINDER_NAME}}",
MAIN: "{{.MP3BINDER_MAIN}}",
GOOS: "darwin",
GOARCH: "amd64",
EXTENSION: "",
}
- task: zip
vars: { NAME: "darwin_amd64" }
# macOS Apple silicon
- task: build-for
vars:
{
NAME: "{{.MP3BINDER_NAME}}",
MAIN: "{{.MP3BINDER_MAIN}}",
GOOS: "darwin",
GOARCH: "arm64",
EXTENSION: "",
}
- task: zip
vars: { NAME: "darwin_arm64" }
- '{{if eq OS "darwin"}}
mkdir -p {{.FOLDER_DIST}}/darwin_universal &&
lipo -create -output {{.FOLDER_DIST}}/darwin_universal/{{.MP3BINDER_NAME}} {{.FOLDER_DIST}}/darwin_amd64/{{.MP3BINDER_NAME}} {{.FOLDER_DIST}}/darwin_arm64/{{.MP3BINDER_NAME}} &&
cd {{.FOLDER_DIST}}/darwin_universal/ && zip -r "../darwin_universal.zip" .
{{end}}'
# linux 64
- task: build-for
vars:
{
NAME: "{{.MP3BINDER_NAME}}",
MAIN: "{{.MP3BINDER_MAIN}}",
GOOS: "linux",
GOARCH: "amd64",
EXTENSION: "",
}
- task: zip
vars: { NAME: "linux_amd64" }
# windows 64
- task: build-for
vars:
{
NAME: "{{.MP3BINDER_NAME}}",
MAIN: "{{.MP3BINDER_MAIN}}",
GOOS: "windows",
GOARCH: "amd64",
EXTENSION: ".exe",
}
- task: zip
vars: { NAME: "windows_amd64" }
test:
desc: Perform all tests
cmds:
- $GO test -cover -race ./...
build:
desc: Build the binary for the current architecture.
deps:
- clean
- test
cmds:
- task: build-for
vars:
{
NAME: "{{.MP3BINDER_NAME}}",
MAIN: "{{.MP3BINDER_MAIN}}",
GOOS: "{{OS}}",
GOARCH: "{{ARCH}}",
EXTENSION: "{{exeExt}}",
}
- task: zip
vars: { NAME: "{{OS}}_{{ARCH}}" }
zip:
vars:
FOLDER: "{{.FOLDER_DIST}}/{{.NAME}}"
summary: Zips the folder
cmds:
- cd "${FOLDER}" && zip -r "../${NAME}.zip" .
generates:
- "{{.FOLDER_DIST}}/{{.NAME}}.zip"
env:
NAME: "{{.NAME}}"
FOLDER: "{{.FOLDER}}"
build-for:
vars:
FOLDER: "{{.FOLDER_DIST}}/{{.GOOS}}_{{.GOARCH}}"
OUTPUT: "{{.FOLDER_DIST}}/{{.GOOS}}_{{.GOARCH}}/{{.NAME}}{{.EXTENSION}}"
summary: Build the binary for a given platform
cmds:
- mkdir -p "{{.FOLDER}}"
- >-
go build -trimpath
-ldflags="-w -s
-X main.name="{{.NAME}}{{.EXTENSION}}"
-X main.version="{{.GIT_COMMIT}}"
-X main.realm="{{.REALM}}"
-extldflags '-static'" -a
-buildvcs=false
-o {{.OUTPUT}}
{{.MAIN}}
generates:
- "{{.OUTPUT}}"
env:
NAME: "{{.NAME}}"
MAIN: "{{.MAIN}}"
GOOS: "{{.GOOS}}"
GOARCH: "{{.GOARCH}}"
GOARM: "{{.GOARM}}"
EXTENSION: "{{.EXTENSION}}"
GIT_COMMIT: "{{.GIT_COMMIT}}"
REALM: "{{.REALM}}"