-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathTaskfile.yml
More file actions
52 lines (47 loc) · 1.99 KB
/
Copy pathTaskfile.yml
File metadata and controls
52 lines (47 loc) · 1.99 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
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
version: "3"
tasks:
default:
cmd: echo "Run the main Taskfile instead of this one."
cli:compile:
desc: Compile CLI binaries
dir: ./cli
vars:
GOOS: "{{ .GOOS | default OS }}"
GOARCH: "{{ .GOARCH | default ARCH }}"
BINARY_NAME: '{{ .BINARY_NAME | default "dirctl" }}'
OUT_BINARY: '{{if .OUT_BINARY}}{{.OUT_BINARY}}{{else}}{{ if eq OS "windows" }}{{ .ROOT_DIR }}\\.bin\\{{ .BINARY_NAME }}.exe{{ else }}{{ .ROOT_DIR }}/.bin/{{ .BINARY_NAME }}{{ end }}{{ end }}'
COVERAGE: '{{ .COVERAGE | default "false" }}'
COVERAGE_FLAGS: '-cover -covermode=atomic -coverpkg={{.COVERAGE_PKGS}}'
LDFLAGS: '-s -w -extldflags -static {{ .VERSION_LDFLAGS }}'
TRY_SKIP_COMPILE: '{{ .TRY_SKIP_COMPILE | default "false" }}'
cmds:
- |
if [ "{{.TRY_SKIP_COMPILE}}" = "true" ]; then
if [ -f "{{.OUT_BINARY}}" ]; then
echo "Binary {{.OUT_BINARY}} already exists, skipping compilation."
exit 0
else
echo "Binary {{.OUT_BINARY}} does not exist, proceeding with compilation."
fi
fi
CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build \
{{if eq .COVERAGE "true"}}{{.COVERAGE_FLAGS}} \
{{else}}-ldflags="{{ .LDFLAGS }}"{{end}} \
-o "{{.OUT_BINARY}}" .
cli:compile:all:
desc: Compile CLI client binaries for multiple platforms
aliases: [compile]
cmds:
- for:
matrix:
OS: ["linux", "darwin", "windows"]
ARCH: ["amd64", "arm64"]
cmd: |
# Skip unsupported combinations (e.g., Windows ARM64)
if [ "{{.ITEM.OS}}" = "windows" ] && [ "{{.ITEM.ARCH}}" = "arm64" ]; then
echo "Skipping unsupported platform: {{.ITEM.OS}}/{{.ITEM.ARCH}}"
else
GOOS={{.ITEM.OS}} GOARCH={{.ITEM.ARCH}} BINARY_NAME=dirctl-{{.ITEM.OS}}-{{.ITEM.ARCH}} task cli:compile
fi