-
Notifications
You must be signed in to change notification settings - Fork 139
/
Taskfile.yml
70 lines (67 loc) · 3.11 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
version: '2'
# expansions: 3
vars:
PWD:
sh: pwd
TAG:
sh: git describe --tags
VERSION: "{{or .BUILD_VERSION .TAG}}"
DATE:
sh: date +%FT%TZ%z
BUILD_DIR: "{{ .PWD }}/build"
tasks:
clean:
cmds:
- go clean
- rm -rf "{{ .BUILD_DIR }}"
test:
cmds:
- go test ./... -race -count=1
lint:
cmds:
- golangci-lint run
build-fs:
cmds:
- go run github.com/mjibson/esc -o cmd/hkcam/fs.go -ignore ".*\.go" html static
hkcam:
cmds:
- task: build-fs
- "go build -o {{ .BUILD_DIR }}/hkcam -ldflags {{ .LDFLAGS }} cmd/hkcam/main.go cmd/hkcam/fs.go"
- "{{ .BUILD_DIR }}/hkcam --verbose --port={{ .PORT }} --data_dir=cmd/hkcam/db"
vars:
LDFLAGS: "\"-X main.Version={{ .VERSION }} -X main.Date={{ .DATE }}\""
PORT: '{{ default "8080" .PORT }}'
sources:
- static/**/*
- cmd/hkcam/main.go
- api/*.go
- app/*.go
- html/**/*
- Taskfile.yml
pack:
cmds:
- task: build-fs
# Raspberry Pi
- "GOOS=linux GOARCH=arm GOARM=6 go build -o {{ .BUILD_DIR }}/{{ .PACKAGE_RPI }}/{{ .BINARY }} -ldflags {{ .LDFLAGS }} cmd/hkcam/main.go cmd/hkcam/fs.go"
# Linux
- "GOOS=linux GOARCH=amd64 go build -o {{ .BUILD_DIR }}/{{ .PACKAGE_LINUX_64 }}/{{ .BINARY }} -ldflags {{ .LDFLAGS }} cmd/hkcam/main.go cmd/hkcam/fs.go"
# Linux
- "GOOS=linux GOARCH=386 go build -o {{ .BUILD_DIR }}/{{ .PACKAGE_LINUX_32 }}/{{ .BINARY }} -ldflags {{ .LDFLAGS }} cmd/hkcam/main.go cmd/hkcam/fs.go"
# Intel Mac
- "GOOS=darwin GOARCH=amd64 go build -o {{ .BUILD_DIR }}/{{ .PACKAGE_INTEL_MAC }}/{{ .BINARY }} -ldflags {{ .LDFLAGS }} cmd/hkcam/main.go cmd/hkcam/fs.go"
# M1 Mac
- "GOOS=darwin GOARCH=arm64 go build -o {{ .BUILD_DIR }}/{{ .PACKAGE_M1_MAC }}/{{ .BINARY }} -ldflags {{ .LDFLAGS }} cmd/hkcam/main.go cmd/hkcam/fs.go"
# pack
- "tar -cvzf {{ .PACKAGE_RPI }}.tar.gz -C {{ .BUILD_DIR }}/{{ .PACKAGE_RPI }} {{ .BINARY }}"
- "tar -cvzf {{ .PACKAGE_LINUX_64 }}.tar.gz -C {{ .BUILD_DIR }}/{{ .PACKAGE_LINUX_64 }} {{ .BINARY }}"
- "tar -cvzf {{ .PACKAGE_LINUX_32 }}.tar.gz -C {{ .BUILD_DIR }}/{{ .PACKAGE_LINUX_32 }} {{ .BINARY }}"
- "tar -cvzf {{ .PACKAGE_INTEL_MAC }}.tar.gz -C {{ .BUILD_DIR }}/{{ .PACKAGE_INTEL_MAC }} {{ .BINARY }}"
- "tar -cvzf {{ .PACKAGE_M1_MAC }}.tar.gz -C {{ .BUILD_DIR }}/{{ .PACKAGE_M1_MAC }} {{ .BINARY }}"
vars:
BINARY: hkcam
PACKAGE_RPI: "{{ .BINARY }}-{{ .VERSION }}_linux_arm"
PACKAGE_LINUX_64: "{{ .BINARY }}-{{ .VERSION }}_linux_amd64"
PACKAGE_LINUX_32: "{{ .BINARY }}-{{ .VERSION }}_linux_386"
PACKAGE_INTEL_MAC: "{{ .BINARY }}-{{ .VERSION }}_darwin_amd64"
PACKAGE_M1_MAC: "{{ .BINARY }}-{{ .VERSION }}_darwin_arm64"
LDFLAGS: "\"-X main.Version={{ .VERSION }} -X main.Date={{ .DATE }}\""