-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
83 lines (71 loc) · 1.98 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
# https://taskfile.dev
version: '3'
dotenv: ['.env']
vars:
url: https://twitcasting.tv/ogurayui1017/movie/702488554
output: dist
module:
sh: grep module go.mod | cut -d ' ' -f 2
commit:
sh: git rev-parse --short HEAD 2>/dev/null || echo 0000000
version:
sh: git describe --tags --abbrev=0 || echo 0.0.0
stem: '{{.module | splitList "/" | last}}'
args:
-trimpath
--ldflags="-w -s -X 'main.Version={{.version}}' -X 'main.Commit={{.commit}}'"
-o {{.output}}
tasks:
default:
desc: run project
cmds:
- go run . -u "{{.url}}"
build:
desc: build current os
cmds:
- rm -rf {{.output}}
- mkdir -p {{.output}}
- go build -o {{.output}} .
build-all:
desc: build all
cmds:
- rm -rf {{.output}}
- mkdir -p {{.output}}
- |-
{{range $_, $os := list "linux" "darwin" "windows" }}
{{- range list "amd64" "arm64"}}
GOOS={{$os}} GOARCH={{.}} go build {{$.args}} .
{{- $ext := (ternary ".exe" "" (eq $os "windows")) }}
{{- $buildPath := (list $.output "/" $.stem $ext | join "") }}
{{- $zipPath := (list $.output "/" $.stem "-" $os "-" . ".zip" | join "") }}
zip -0j -q {{$zipPath}} {{$buildPath}}
rm -f {{$buildPath}}
{{- $dgst := (list $zipPath ".dgst" | join "")}}
{{- range list "md5" "sha1" "sha256" "sha512"}}
openssl dgst -{{.}} {{$dgst}} | sed 's/([^)]*)//g' >> {{$dgst}}
{{- end -}}
{{- end -}}
{{- end -}}
release:
desc: public releases
cmds:
- gh release create {{.version}} dist/*
tidy:
desc: mod tidy
cmds:
- go mod tidy
install:
desc: install project
cmds:
- cp -f {{.output}}/{{.stem}}{{exeExt}} $GOPATH/bin
uninstall:
desc: uninstall project
cmds:
- rm -f $GOPATH/bin/{{.stem}}{{exeExt}}
clean:
desc: delete cache files
cmds:
- rm -rf {{.output}}
- rm -f *.log
- rm -rf .temp-*
- rm -f *.mp4