-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.goreleaser.yml
347 lines (286 loc) · 10.5 KB
/
.goreleaser.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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
project_name: c8y
release:
prerelease: auto
draft: true # we only publish after the Windows MSI gets uploaded
name_template: "Cumulocity CLI {{.Version}}"
builds:
- <<: &build_defaults
binary: 'bin/{{ if index .Env "BINARY_INCLUDE_VERSION" }}{{ .ProjectName }}_{{ .RawVersion }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}{{ else }}{{ .ProjectName }}{{ end }}'
main: ./cmd/c8y/main.go
flags:
- -trimpath
ldflags:
- -s -w -X github.com/reubenmiller/go-c8y-cli/v2/pkg/cmd.buildVersion={{.Version}} -X github.com/reubenmiller/go-c8y-cli/v2/pkg/cmd.buildBranch={{.Branch}}
hooks:
post:
- echo "Copying binaries for PowerShell Module"
- bash -c 'test -d output_pwsh && cp "{{ .Path }}" output_pwsh/PSc8y/Dependencies/{{ .ProjectName }}_{{ .RawVersion }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}{{ if eq .Os "windows" }}.exe{{ end }} || echo "Skipped pwsh output"'
id: macOS
goos: [darwin]
goarch: [amd64, arm64]
- <<: *build_defaults
id: linux
goos: [linux]
goarch: ["386", arm, amd64, arm64]
goarm:
- "5"
- "6"
- "7"
env:
- CGO_ENABLED=0
- <<: *build_defaults
id: windows
goos: [windows]
goarch: ["386", amd64, arm64]
archives:
- id: nix
builds: [linux]
<<: &archive_defaults
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
wrap_in_directory: "true"
format: tar.gz
files:
- LICENSE
- ./share/man/man1/c8y*.1
- .go-c8y-cli/README.md
- .go-c8y-cli/install.*
- .go-c8y-cli/settings.*
- .go-c8y-cli/shell
- .go-c8y-cli/templates
- .go-c8y-cli/views
- id: homebrew
builds: [macOS]
<<: *archive_defaults
wrap_in_directory: "true"
format: tar.gz
files:
- LICENSE
- ./share/man/man1/c8y*.1
- .go-c8y-cli/README.md
- .go-c8y-cli/install.*
- .go-c8y-cli/settings.*
- .go-c8y-cli/shell
- .go-c8y-cli/templates
- .go-c8y-cli/views
- id: windows
builds: [windows]
<<: *archive_defaults
wrap_in_directory: "false"
format: zip
files:
- LICENSE
- .go-c8y-cli/README.md
- .go-c8y-cli/install.*
- .go-c8y-cli/settings.*
- .go-c8y-cli/shell
- .go-c8y-cli/templates
- .go-c8y-cli/views
- id: plainBinaries
builds: [macOS, linux, windows]
# Don't include the binary in the filename so it is easier to download the latest
<<: &archive_defaults
name_template: '{{ .ProjectName }}_{{ if eq .Os "darwin" }}macOS{{ else }}{{ .Os }}{{ end }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
format: binary
nfpms:
-
# id: go-c8y-cli
package_name: go-c8y-cli
license: MIT
maintainer: Reuben Miller <[email protected]>
homepage: http://goc8ycli.netlify.app
bindir: /usr
description: Cumulocity IoT command line tool
section: utils
priority: optional
file_name_template: "{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
formats:
- deb
- rpm
- apk
# Packages your package suggests installing.
suggests:
- jq
- git
contents:
# Man pages
- src: "./share/man/man1/c8y*.1"
dst: "/usr/share/man/man1"
# Completions
- src: ./output/bash/c8y
dst: /etc/bash_completion.d/c8y
- src: ./output/zsh/_c8y
dst: /usr/share/zsh/site-functions/_c8y
- src: ./output/fish/c8y.fish
dst: /usr/share/fish/vendor_completions.d/c8y.fish
# Addons
- src: .go-c8y-cli/settings.*
dst: /etc/go-c8y-cli/
type: config|noreplace
- src: .go-c8y-cli/shell
dst: /etc/go-c8y-cli/shell
type: config
- src: .go-c8y-cli/templates
dst: /etc/go-c8y-cli/templates
type: config
- src: .go-c8y-cli/views
dst: /etc/go-c8y-cli/views
type: config
brews:
-
# Package name
name: go-c8y-cli
# IDs of the archives to use.
ids:
- homebrew
- nix
# GOARM to specify which 32-bit arm version to use if there are multiple versions
# from the build section. Brew formulas support atm only one 32-bit version.
# Default is 6 for all artifacts or each id if there a multiple versions.
goarm: "6"
# GitHub/GitLab repository to push the formula to
repository:
owner: reubenmiller
name: homebrew-go-c8y-cli
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
# Template for the url which is determined by the given Token
url_template: "https://github.com/reubenmiller/go-c8y-cli/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
# Git author used to commit to the repository.
commit_author:
name: goreleaserbot
email: [email protected]
# Folder inside the repository to put the formula.
directory: Formula
# Caveats for the user of your binary.
caveats: |
Please add the following to your shell profile to enable usage of "set-session" and other helpful c8y utility functions
bash: ~/.bashrc
source "#{etc}/go-c8y-cli/shell/c8y.plugin.sh"
zsh: ~/.zshrc
source "#{etc}/go-c8y-cli/shell/c8y.plugin.zsh"
fish: ~/.config/fish/config.fish
source "#{etc}/go-c8y-cli/shell/c8y.plugin.fish"
powershell: ~/.config/powershell/Microsoft.PowerShell_profile.ps1
. "#{etc}/go-c8y-cli/shell/c8y.plugin.ps1"
You will also need to force reload of your profile:
source <profile>
homepage: "https://goc8ycli.netlify.app/"
description: "Cumulocity IoT command line tool"
license: "MIT"
dependencies:
- name: git
type: optional
- name: jq
type: optional
- name: zsh
type: optional
- name: bash
type: optional
- name: fish
type: optional
# So you can `brew test` your formula.
test: |
system "#{bin}/c8y version --select version"
install: |
bin.install "bin/c8y"
man1.install Dir["share/man/man1/*"]
config_dir = etc/"go-c8y-cli"
if config_dir.exist?
# FileUtils.rm_r etc/"go-c8y-cli"
system "git", "-C", config_dir, "pull", "--ff-only"
else
system "git", "clone", "--depth", "1", "https://github.com/reubenmiller/go-c8y-cli-addons.git", config_dir
end
# Add completions
output = Utils.safe_popen_read({ "SHELL" => "bash" }, "#{bin}/c8y", "completion", "bash")
(bash_completion/"c8y").write output
output = Utils.safe_popen_read({ "SHELL" => "zsh" }, "#{bin}/c8y", "completion", "zsh")
(zsh_completion/"_c8y").write output
output = Utils.safe_popen_read({ "SHELL" => "fish" }, "#{bin}/c8y", "completion", "fish")
(fish_completion/"c8y.fish").write output
dockers:
- dockerfile: docker/shell.dockerfile
use: buildx
goarch: amd64
# Templates of the Docker image names.
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:latest-amd64"
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:{{ .Tag }}-amd64"
# Template of the docker build flags.
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/amd64"
- dockerfile: docker/shell.dockerfile
use: buildx
goarch: arm64
# Templates of the Docker image names.
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:latest-arm64v8"
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:{{ .Tag }}-arm64v8"
# Template of the docker build flags.
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/arm64/v8"
#
# pwsh image
#
- dockerfile: docker/pwsh.dockerfile
use: buildx
goarch: amd64
# Templates of the Docker image names.
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:latest-amd64"
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:{{ .Tag }}-amd64"
# Template of the docker build flags.
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/amd64"
extra_files:
- docker/profile.ps1
- output_pwsh/PSc8y
- dockerfile: docker/pwsh.dockerfile
use: buildx
goarch: arm64
# Templates of the Docker image names.
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:latest-arm64v8"
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:{{ .Tag }}-arm64v8"
# Template of the docker build flags.
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/arm64/v8"
extra_files:
- docker/profile.ps1
- output_pwsh/PSc8y
docker_manifests:
- name_template: "ghcr.io/reubenmiller/{{.ProjectName}}-shell:{{ .Tag }}"
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:{{ .Tag }}-amd64"
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:{{ .Tag }}-arm64v8"
- name_template: "ghcr.io/reubenmiller/{{.ProjectName}}-shell:latest"
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:latest-amd64"
- "ghcr.io/reubenmiller/{{.ProjectName}}-shell:latest-arm64v8"
- name_template: "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:{{ .Tag }}"
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:{{ .Tag }}-amd64"
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:{{ .Tag }}-arm64v8"
- name_template: "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:latest"
image_templates:
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:latest-amd64"
- "ghcr.io/reubenmiller/{{.ProjectName}}-pwsh:latest-arm64v8"