-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTaskfile.yml
More file actions
172 lines (150 loc) · 5.84 KB
/
Copy pathTaskfile.yml
File metadata and controls
172 lines (150 loc) · 5.84 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
169
170
171
version: "3"
vars:
BINARY: harness
MAIN: ./cmd/harness/main-harness.go
# devhome doubles as a dev HARNESS_CLI_HOME: plugin binaries live in
# devhome/bin and their specs (grammar + provenance) in devhome/spec, exactly
# as ~/.harness would hold them in production. Run the CLI against it with:
# HARNESS_CLI_HOME=devhome ./bin/harness ...
# Gitignored and visible (not dot-prefixed) so specs are easy to inspect.
DEVHOME: devhome
VERSION:
sh: echo "${VERSION:-$(go run ./cmd/getversion/main-getversion.go --next)-dev}"
HAR_VERSION:
sh: echo "${HAR_VERSION:-$(go run ./cmd/getversion/main-getversion.go --next --prefix=har/)-dev}"
BUILD_TIME:
sh: date -u +%Y%m%d%H%MZ
SEGMENT_WRITE_KEY: '{{default "" (env "SEGMENT_WRITE_KEY")}}'
LDFLAGS: >-
-X github.com/harness/cli/pkg/hbase.Version={{.VERSION}}
-X github.com/harness/cli/pkg/hbase.BuildTime={{.BUILD_TIME}}
-X github.com/harness/cli/pkg/telemetry.segmentWriteKey={{.SEGMENT_WRITE_KEY}}
HAR_LDFLAGS: >-
-X github.com/harness/cli/pkg/hbase.Version={{.HAR_VERSION}}
-X github.com/harness/cli/pkg/hbase.BuildTime={{.BUILD_TIME}}
-X github.com/harness/cli/pkg/telemetry.segmentWriteKey={{.SEGMENT_WRITE_KEY}}
tasks:
build:
desc: Build all binaries
deps: [build:main, build:har]
build:main:
desc: Build the harness binary
# once: several tasks depend on this (build:har, check:specs, install). Without
# it Task's default run:always rebuilds bin/harness for each dependent, and
# parallel deps race on the same output path.
run: once
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o bin/{{.BINARY}} {{.MAIN}}
build:har:
desc: Build the harness-har binary into devhome/bin (dev plugin home)
run: once
cmds:
- mkdir -p {{.DEVHOME}}/bin
# Plugins used to build into bin/ (next to bin/harness, where FindBinary
# looks first). Remove any leftover so it can't shadow the devhome copy.
- rm -f bin/harness-har
- cd modules/har && go build -ldflags "{{.HAR_LDFLAGS}}" -o ../../{{.DEVHOME}}/bin/harness-har ./cmd/harness-har/main-harness-har.go
- task: dev:plugin:har
dev:plugin:har:
desc: Install the built harness-har binary into devhome via `install plugin`
internal: true
# The installer is bin/harness itself, hence the build:main dep.
deps: [build:main]
cmds:
# Use the real installer path: `install plugin` runs the identity gate,
# captures --spec, and stamps provenance into devhome/spec. Exactly what a
# user gets from `harness install plugin <binary>`.
- HARNESS_CLI_HOME={{.DEVHOME}} ./bin/{{.BINARY}} install plugin {{.DEVHOME}}/bin/harness-har
- echo "Run with HARNESS_CLI_HOME={{.DEVHOME}} ./bin/harness ..."
build:windows:
desc: Cross-compile Windows binaries (harness.exe + harness-har.exe)
deps: [build:windows:main, build:windows:har]
build:windows:main:
desc: Cross-compile harness.exe for Windows amd64
env:
GOOS: windows
GOARCH: amd64
CGO_ENABLED: 0
cmds:
- go build -ldflags "{{.LDFLAGS}}" -o bin/harness.exe {{.MAIN}}
build:windows:har:
desc: Cross-compile harness-har.exe for Windows amd64
dir: modules/har
env:
GOOS: windows
GOARCH: amd64
CGO_ENABLED: 0
cmds:
- go build -ldflags "{{.HAR_LDFLAGS}}" -o ../../bin/harness-har.exe ./cmd/harness-har/main-harness-har.go
build:opt:
desc: Report release binary sizes (goreleaser's flags; bin/opt-* are throwaway)
cmds:
# Same flags as .goreleaser.yaml, so these sizes match what ships. Written
# to bin/opt-* rather than the normal paths: this is only for reading sizes,
# so it must not clobber the debuggable binaries or the devhome plugin.
- mkdir -p bin
- go build -trimpath -ldflags "{{.LDFLAGS}} -s -w" -o bin/opt-{{.BINARY}} {{.MAIN}}
- cd modules/har && go build -trimpath -ldflags "{{.HAR_LDFLAGS}} -s -w" -o ../../bin/opt-{{.BINARY}}-har ./cmd/harness-har/main-harness-har.go
- ls -lh bin/opt-*
install:
desc: Build and install harness binary to ~/.local/bin
deps: [build:main]
cmds:
- mkdir -p ~/.local/bin
- cp bin/{{.BINARY}} ~/.local/bin/{{.BINARY}}
- echo "Installed ~/.local/bin/{{.BINARY}}"
install:har:
desc: Build and install harness-har binary to ~/.local/bin
deps: [build:har, install]
cmds:
- mkdir -p ~/.local/bin
- cp ./bin/harness-har ~/.local/bin/harness-har
- echo "Installed ~/.local/bin/harness-har"
dev:
desc: Run without ldflags (version shows 0.1.0-dev / dev)
cmds:
- go run {{.MAIN}} {{.CLI_ARGS}}
check:specs:
desc: Validate all *.spec.yaml files
deps: [build:main, build:har]
cmds:
- HARNESS_CHECKSPECS=1 ./bin/harness
- HARNESS_CHECKSPECS=1 ./{{.DEVHOME}}/bin/harness-har
check:specs:main:
desc: Validate core *.spec.yaml files (skips HAR build)
deps: [build:main]
cmds:
- HARNESS_CHECKSPECS=1 ./bin/harness
test:
desc: Run all unit tests
deps: [test:main, test:har]
test:main:
desc: Run unit tests for the main module
cmds:
- go test ./...
test:har:
desc: Run unit tests for the HAR external module
dir: modules/har
cmds:
- go test ./...
tidy:
desc: Tidy all modules and sync go.work
cmds:
- go mod tidy
- sh -c "cd modules/har && go mod tidy"
- go work sync
release:simple:
desc: Publish a release to GitHub (skips dirty check, no release notes)
cmds:
- goreleaser release --clean --release-notes /dev/null
release:har:
desc: 'Build (and optionally publish) the har plugin release (usage: task release:har -- har/v3.1.0 [--publish])'
cmds:
- ./scripts/release-har.sh {{.CLI_ARGS}}
clean:
desc: Remove built binaries
cmds:
- rm -rf bin/
- rm -rf dist/
- rm -rf dist-plugins/
- rm -rf devhome/