-
Notifications
You must be signed in to change notification settings - Fork 494
451 lines (451 loc) · 16.1 KB
/
main.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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
name: main
on:
pull_request:
branches:
- master
push:
branches:
- master
tags:
- v*
env:
ACTIONLINT_VERSION: 1.6.25
AGE_VERSION: 1.1.1
GO_VERSION: 1.21.0
GOFUMPT_VERSION: 0.4.0
GOLANGCI_LINT_VERSION: 1.54.2
GOLINES_VERSION: 0.11.0
GOVERSIONINFO_VERSION: 1.4.0
FINDTYPOS_VERSION: 0.0.1
MKDOCS_VERSION: 1.5.2
jobs:
changes:
runs-on: ubuntu-20.04
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- id: filter
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
with:
filters: |
code:
- '**/*.go'
- '**/*.ps1'
- '**/*.tmpl'
- '.github/workflows/**'
- '.goreleaser.yaml'
- 'Makefile'
- 'assets/docker/**'
- 'assets/scripts/**'
- 'assets/vagrant/**'
- 'go.*'
- 'internal/**'
codeql:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-20.04
permissions:
security-events: write
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
fetch-depth: 1
- uses: github/codeql-action/init@0ba4244466797eb048eb91a6cd43d5c03ca8bd05
with:
languages: go
- uses: github/codeql-action/analyze@0ba4244466797eb048eb91a6cd43d5c03ca8bd05
misspell:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: reviewdog/action-misspell@9257f108197b44e37995c98bea6ee4a5b9ffc3b0
with:
locale: US
test-alpine:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh alpine )
test-archlinux:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh archlinux )
test-debian-i386:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: macos-12
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ~/.vagrant.d
key: ${{ runner.os }}-vagrant-debian-i386-${{ hashFiles('assets/vagrant/debian11-i386.Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-debian-i386-
- name: test
run: |
( cd assets/vagrant && ./test.sh debian11-i386 )
test-fedora:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
( cd assets/docker && ./test.sh fedora )
test-macos:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: macos-11
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: build
run: |
go build ./...
- name: run
run: |
go run . --version
- name: install-age
run: |
cd "$(mktemp -d)"
curl -fsSL "https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-darwin-amd64.tar.gz" | tar xzf -
sudo install -m 755 age/age /usr/local/bin
sudo install -m 755 age/age-keygen /usr/local/bin
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -race ./...
- name: test-install.sh
run: |
sh assets/scripts/install.sh
bin/chezmoi --version
test-oldstable-go:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: oldstable
- name: build
run: |
go build ./...
- name: run
run: |
go run . --version
- name: install-age
run: |
cd "$(mktemp -d)"
curl -fsSL "https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-amd64.tar.gz" | tar xzf -
sudo install -m 755 age/age /usr/local/bin
sudo install -m 755 age/age-keygen /usr/local/bin
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test ./...
test-release:
needs: changes
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
fetch-depth: 0
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: install-release-dependencies
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
run: |
sudo apt-get --quiet update
sudo apt-get --no-install-suggests --no-install-recommends --quiet --yes install musl-tools snapcraft
# https://github.com/goreleaser/goreleaser/issues/1715
# https://bugs.launchpad.net/snapcraft/+bug/1889741
mkdir -p "${HOME}/.cache/snapcraft/download"
mkdir -p "${HOME}/.cache/snapcraft/stage-packages"
- name: create-syso
run: |
make create-syso
- name: build-release
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7
with:
version: latest
args: release --skip-publish --skip-sign --snapshot --timeout=1h
- name: upload-artifact-chezmoi-darwin-amd64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: chezmoi-darwin-amd64
path: dist/chezmoi-nocgo_darwin_amd64_v1/chezmoi
- name: upload-artifact-chezmoi-darwin-arm64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: chezmoi-darwin-arm64
path: dist/chezmoi-nocgo_darwin_arm64/chezmoi
- name: upload-artifact-chezmoi-linux-amd64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: chezmoi-linux-amd64
path: dist/chezmoi-cgo-glibc_linux_amd64_v1/chezmoi
- name: upload-artifact-chezmoi-linux-musl-amd64
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: chezmoi-linux-amd64-musl
path: dist/chezmoi-cgo-musl_linux_amd64_v1/chezmoi
- name: upload-artifact-chezmoi-windows-amd64.exe
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: chezmoi-windows-amd64
path: dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe
test-ubuntu:
needs: changes
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
fetch-depth: 0
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: install-age
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
run: |
cd "$(mktemp -d)"
curl -fsSL "https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-amd64.tar.gz" | tar xzf -
sudo install -m 755 age/age /usr/local/bin
sudo install -m 755 age/age-keygen /usr/local/bin
- name: build
run: |
go build ./...
- name: run
run: |
go run . --version
- name: test-umask-022
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o022" -race ./...
- name: test-umask-002
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -ldflags="-X github.com/twpayne/chezmoi/v2/internal/chezmoitest.umaskStr=0o002" -race ./...
- name: test-install.sh
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
run: |
rm -f bin/chezmoi
sh assets/scripts/install.sh
bin/chezmoi --version
test-website:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: install-website-dependencies
run: |
pip3 install mkdocs==${{ env.MKDOCS_VERSION }}
pip3 install -r assets/chezmoi.io/requirements.txt
- name: build-website
run: ( cd assets/chezmoi.io && mkdocs build )
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
test-windows:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: windows-2022
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: build
run: |
go build ./...
- name: run
run: |
go run . --version
- name: test
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
run: |
go test -race ./...
- name: test-install.ps1
run: |
if (Test-Path -Path bin/chezmoi.exe) { Remove-Item -Force bin/chezmoi.exe }
powershell -c assets/scripts/install.ps1
bin/chezmoi.exe --version
- name: test-install-irm
run: |
if (Test-Path -Path bin/chezmoi.exe) { Remove-Item -Force bin/chezmoi.exe }
(irm -useb https://get.chezmoi.io/ps1) | powershell -c -
bin/chezmoi.exe --version
- name: test-install-iwr
run: |
if (Test-Path -Path bin/chezmoi.exe) { Remove-Item -Force bin/chezmoi.exe }
(iwr -useb https://get.chezmoi.io/ps1).ToString() | powershell -c -
bin/chezmoi.exe --version
check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: generate
run: |
go generate
git diff --exit-code
- name: actionlint
run: |
go install "github.com/rhysd/actionlint/cmd/actionlint@v${ACTIONLINT_VERSION}"
actionlint
- uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
with:
ignore_paths: completions
- name: lint-whitespace
run: |
go run ./internal/cmds/lint-whitespace
- name: lint-txtar
run: |
find . -name '*.txtar' -print0 | xargs -0 go run ./internal/cmds/lint-txtar
- name: findtypos
run: |
go install "github.com/twpayne/findtypos@v${FINDTYPOS_VERSION}"
findtypos -format=github-actions chezmoi .
lint:
needs: changes
if: github.event_name == 'push' || needs.changes.outputs.code == 'true'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299
with:
version: v${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m
release: # FIXME this should be merged into test-release above
if: startsWith(github.ref, 'refs/tags/')
needs:
- check
- lint
- test-alpine
- test-archlinux
- test-debian-i386
- test-fedora
- test-macos
- test-oldstable-go
- test-release
- test-ubuntu
- test-website
- test-windows
runs-on: ubuntu-20.04
steps:
- name: install-build-dependencies
run: |
sudo apt-get --quiet update
sudo apt-get --no-install-suggests --no-install-recommends --quiet --yes install musl-tools snapcraft
# https://github.com/goreleaser/goreleaser/issues/1715
# https://bugs.launchpad.net/snapcraft/+bug/1889741
mkdir -p "${HOME}/.cache/snapcraft/download"
mkdir -p "${HOME}/.cache/snapcraft/stage-packages"
- name: check-snapcraft-credentials
run: snapcraft whoami
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
fetch-depth: 0
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06
- name: create-syso
run: |
make create-syso
- uses: goreleaser/goreleaser-action@336e29918d653399e599bfca99fadc1d7ffbc9f7
with:
version: latest
args: release --timeout=1h
env:
COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
SCOOP_GITHUB_TOKEN: ${{ secrets.SCOOP_GITHUB_TOKEN }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
deploy-website:
needs:
- release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
fetch-depth: 0
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
with:
go-version: ${{ env.GO_VERSION }}
- name: prepare-chezmoi.io
run: |
pip3 install mkdocs==${{ env.MKDOCS_VERSION }}
pip3 install -r assets/chezmoi.io/requirements.txt
( cd assets/chezmoi.io && mkdocs build )
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
- name: push-chezmoi.io
run: |
( cd assets/chezmoi.io && mkdocs gh-deploy )
- name: prepare-get.chezmoi.io
run: |
cp assets/scripts/install.sh assets/get.chezmoi.io/index.html
cp assets/scripts/install-local-bin.sh assets/get.chezmoi.io/lb
cp assets/scripts/install.ps1 assets/get.chezmoi.io/ps1
cp LICENSE assets/get.chezmoi.io/LICENSE
- name: push-get.chezmoi.io
uses: cpina/github-action-push-to-another-repository@cbe757f8d8b380dd2b3ceec5a80fbcd61f1f3107
env:
SSH_DEPLOY_KEY: ${{ secrets.GET_CHEZMOI_IO_SSH_DEPLOY_KEY }}
with:
source-directory: assets/get.chezmoi.io
destination-github-username: chezmoi
destination-repository-name: get.chezmoi.io
target-branch: gh-pages
commit-message: 'chore: Update from ORIGIN_COMMIT'
user-email: [email protected]