-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
90 lines (87 loc) · 2.33 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
# https://taskfile.dev
version: "3"
vars:
GREETING: gotail tasks
targetbin: ~/bin
buildname: gotail
tmpdir: gotailtmp
tasks:
default:
cmds:
- echo "{{.GREETING}}"
silent: true
test:
desc: run tests
cmds:
- cmd: GOOS={{OS}} GOOARCH={{ARCH}} go test -v ./...
run:
desc: run gotail
dir: ./cmd/gotail
vars:
testname: "{{.buildname}}_test{{exeExt}}"
cmds:
- task: build
- mv ./{{.buildname}}{{exeExt}} ./{{.testname}}
- mkdir -p ./{{.tmpdir}}
- rm -f ./{{.tmpdir}}/*txt
- echo "hello" > ./{{.tmpdir}}/1.txt
- echo "hello 2" > ./{{.tmpdir}}/2.txt
- ./{{.testname}} -f -G "./{{.tmpdir}}/*txt" &
- echo "goodbye" > ./{{.tmpdir}}/3.txt
- sleep 2
- rm -rf ./{{.tmpdir}}
- rm ./{{.testname}}
- sleep 2
- killall "{{.testname}}"
clearbin:
desc: clear build in bin dir
cmds:
- cmd: rm {{.targetbin}}/{{.buildname}}
ignore_error: true
# install:
# desc: copy build file to local bin
# dir: .
# preconditions:
# - test -d {{.targetbin}}/
# cmds:
# - task: build
# - task: clearbin
# - cp ./{{.buildname}} {{.targetbin}}/{{.buildname}}
# - rm ./{{.buildname}}
build:
dir: .
cmds:
- goreleaser release --snapshot --rm-dist
install:
vars:
ARCH_VER:
sh: if [[ "{{ARCH}}" = "amd64" ]]; then echo "_v1"; else echo ""; fi
dir: ./dist/{{.buildname}}_{{OS}}_{{ARCH}}{{.ARCH_VER}}/
desc: "install in local bin directory"
cmds:
- task: build
- cmd: rm {{.targetbin}}/{{.buildname}}
ignore_error: true
- cp ./{{.buildname}} {{.targetbin}}
- cmd: echo "{{.completionmsg}}"
silent: true
release:
dir: .
desc: release to github using goreleaser
cmds:
- goreleaser release --rm-dist
macosarm:
desc: build for macos ARM
cmds:
- GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o {{.buildname}}{{exeExt}}
- file ./{{.buildname}}
macosamd:
desc: build for macos AMD
cmds:
- GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o {{.buildname}}{{exeExt}}
- file ./{{.buildname}}
windowsamd:
desc: build for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o {{.buildname}}{{exeExt}}
- file ./{{.buildname}}