-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
169 lines (148 loc) · 5.41 KB
/
Copy pathTaskfile.yml
File metadata and controls
169 lines (148 loc) · 5.41 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
version: '3'
vars:
BINARY_NAME: spark
GO: go
VERSION:
sh: cat internal/witr/version/VERSION 2>/dev/null || echo dev
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo unknown
BUILD_DATE:
sh: date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo unknown
env:
CGO_ENABLED: '0'
tasks:
default:
cmds:
- task: build
build:
desc: Build for current OS, stamp version, install to ~/.local/bin
cmds:
- task: clean
- cmd: '{{.GO}} build -ldflags="-s -w -X spark/internal/witr/version.Version=v{{.VERSION}} -X spark/internal/witr/version.Commit={{.COMMIT}} -X spark/internal/witr/version.BuildDate={{.BUILD_DATE}}" -o {{.BINARY_NAME}}{{exeExt}} main.go'
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install-binary.ps1 -Source '{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/install-binary.sh {{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-install.ps1 -Source '{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/verify-install.sh {{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
- echo 'Installed {{.BINARY_NAME}} to ~/.local/bin'
sources:
- '**/*.go'
- go.mod
generates:
- '{{.BINARY_NAME}}{{exeExt}}'
build:linux:
desc: Cross-compile for Linux (amd64)
cmds:
- task: cross-build
vars:
GOOS: linux
GOARCH: amd64
OUTPUT: '{{.BINARY_NAME}}_linux'
build:linux:arm64:
desc: Cross-compile for Linux (arm64)
cmds:
- task: cross-build
vars:
GOOS: linux
GOARCH: arm64
OUTPUT: '{{.BINARY_NAME}}_linux_arm64'
build:darwin:
desc: Cross-compile for macOS (amd64)
cmds:
- task: cross-build
vars:
GOOS: darwin
GOARCH: amd64
OUTPUT: '{{.BINARY_NAME}}_darwin'
build:darwin:arm64:
desc: Cross-compile for macOS (arm64/Apple Silicon)
cmds:
- task: cross-build
vars:
GOOS: darwin
GOARCH: arm64
OUTPUT: '{{.BINARY_NAME}}_darwin_arm64'
build:windows:
desc: Cross-compile for Windows (amd64)
cmds:
- task: cross-build
vars:
GOOS: windows
GOARCH: amd64
OUTPUT: '{{.BINARY_NAME}}_windows.exe'
build:windows:arm64:
desc: Cross-compile for Windows (arm64)
cmds:
- task: cross-build
vars:
GOOS: windows
GOARCH: arm64
OUTPUT: '{{.BINARY_NAME}}_windows_arm64.exe'
build:all:
desc: Cross-compile for all platforms
cmds:
- task: build:linux
- task: build:linux:arm64
- task: build:darwin
- task: build:darwin:arm64
- task: build:windows
- task: build:windows:arm64
test:
desc: Run all tests
cmds:
- '{{.GO}} test ./... -v'
test-bdd:
desc: Run BDD tests with Ginkgo
cmds:
- '{{.GO}} run github.com/onsi/ginkgo/v2/ginkgo -v ./internal/...'
lint:
desc: Run go vet
cmds:
- '{{.GO}} vet ./...'
clean:
desc: Remove build artifacts
cmds:
- cmd: powershell -NoProfile -Command "Remove-Item -Force -ErrorAction SilentlyContinue spark.exe,spark_windows.exe,spark_windows_arm64.exe,spark_linux,spark_linux_arm64,spark_darwin,spark_darwin_arm64; exit 0"
platforms: [windows]
- cmd: 'rm -f {{.BINARY_NAME}} {{.BINARY_NAME}}.exe {{.BINARY_NAME}}_linux {{.BINARY_NAME}}_linux_arm64 {{.BINARY_NAME}}_darwin {{.BINARY_NAME}}_darwin_arm64 {{.BINARY_NAME}}_windows.exe {{.BINARY_NAME}}_windows_arm64.exe'
platforms: [linux, darwin]
- '{{.GO}} clean'
install:
desc: Build and install to ~/.local/bin
cmds:
- task: build
run:
desc: Build and run
cmds:
- task: build
- './{{.BINARY_NAME}}{{exeExt}} --help'
install-binary:
desc: Copy the already-built binary into ~/.local/bin (no rebuild)
cmds:
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install-binary.ps1 -Source '{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/install-binary.sh {{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-install.ps1 -Source '{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/verify-install.sh {{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
verify-install:
desc: Compare installed binary sha256 against source
cmds:
- cmd: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/verify-install.ps1 -Source '{{.BINARY_NAME}}.exe' -InstallDir $HOME/.local/bin
platforms: [windows]
- cmd: 'bash scripts/verify-install.sh {{.BINARY_NAME}}{{exeExt}} $HOME/.local/bin'
platforms: [linux, darwin]
cross-build:
internal: true
requires:
vars: [GOOS, GOARCH, OUTPUT]
cmds:
- cmd: '{{.GO}} build -ldflags="-s -w -X spark/internal/witr/version.Version=v{{.VERSION}} -X spark/internal/witr/version.Commit={{.COMMIT}} -X spark/internal/witr/version.BuildDate={{.BUILD_DATE}}" -o {{.OUTPUT}} main.go'
env:
GOOS: '{{.GOOS}}'
GOARCH: '{{.GOARCH}}'