-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
110 lines (97 loc) · 2.71 KB
/
Copy pathTaskfile.yml
File metadata and controls
110 lines (97 loc) · 2.71 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
version: "3"
vars:
IMAGE: ghcr.io/xusenlin/workavera
VERSION:
sh: cat VERSION
tasks:
default:
desc: List available tasks
cmds:
- task --list
silent: true
dev:ui:
desc: Start the frontend development server
dir: frontend
cmds:
- pnpm dev
dev:go:
desc: Start the Go backend development server
cmds:
- go run -ldflags="-X main.version={{.VERSION}}" . serve
build:ui:
desc: Build frontend assets on the host
dir: frontend
cmds:
- pnpm build
build:go:
desc: Build the Go binary (embeds frontend/dist; run build:ui first)
cmds:
- go build -trimpath -ldflags="-s -w -X main.version={{.VERSION}}" -o workavera .
build:
desc: Build the frontend and package the self-contained Go binary
cmds:
- task: build:ui
- task: build:go
release:
desc: Cross-compile and package self-contained release archives for Linux/macOS/Windows into dist/
deps:
- build:ui
cmds:
- rm -rf dist && mkdir -p dist
- |
for platform in "linux/amd64" "darwin/amd64" "darwin/arm64" "windows/amd64"; do
GOOS="${platform%/*}"
GOARCH="${platform#*/}"
bin="workavera"
[ "$GOOS" = "windows" ] && bin="workavera.exe"
name="workavera_{{.VERSION}}_${GOOS}_${GOARCH}"
echo "==> building ${name}"
CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" go build \
-trimpath \
-ldflags="-s -w -X main.version={{.VERSION}}" \
-o "dist/$bin" .
if [ "$GOOS" = "windows" ]; then
(cd dist && zip -q "${name}.zip" "$bin")
else
tar -czf "dist/${name}.tar.gz" -C dist "$bin"
fi
rm "dist/$bin"
done
- |
cd dist && { command -v sha256sum >/dev/null 2>&1 \
&& sha256sum workavera_* \
|| shasum -a 256 workavera_*; } > SHA256SUMS.txt
- echo "Release archives generated in dist/ (version {{.VERSION}})"
run:
desc: Build and run the Go binary
deps:
- build:go
cmds:
- ./workavera serve
build:docker:
desc: Build frontend assets and the local Docker image
deps:
- build:ui
cmds:
- docker build --build-arg VERSION={{.VERSION}} -t {{.IMAGE}}:latest .
push:
desc: Build and push the linux/amd64 image for the CentOS server
deps:
- build:ui
cmds:
- >-
docker buildx build
--platform linux/amd64
--build-arg VERSION={{.VERSION}}
--tag {{.IMAGE}}:{{.VERSION}}
--tag {{.IMAGE}}:latest
--push
.
test:
desc: Run tests
cmds:
- go test ./...
tidy:
desc: Tidy Go module dependencies
cmds:
- go mod tidy