225 lines (225 loc) · 7.24 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
name: main
on:
pull_request:
push:
branches:
- master
tags:
- v*
jobs:
test:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-18.04
- windows-latest
env:
AGE_VERSION: v1.0.0-rc.3
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.7
- name: Checkout
uses: actions/checkout@v2
- name: Cache Go modules
uses: actions/cache@v2
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: Install age (Linux/macOS)
if: runner.os == 'Linux' || runner.os == 'macOS' # FIXME add Windows
run: |
cd $(mktemp -d)
goos=$(uname -s | tr '[:upper:]' '[:lower:]')
curl -fsSL https://github.com/FiloSottile/age/releases/download/${AGE_VERSION}/age-${AGE_VERSION}-${goos}-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: Install gpg4win (Windows)
if: runner.os == 'Windows'
run: |
$env:PATH = "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin"
[Environment]::SetEnvironmentVariable("Path", $env:PATH, "Machine")
choco install --yes gpg4win
echo "C:\Program Files (x86)\GnuPG\bin" >> $env:GITHUB_PATH
- name: Test (umask 022)
if: runner.os != 'Windows'
run: go test -ldflags="-X github.com/twpayne/chezmoi/internal/chezmoitest.umaskStr=0o022" -race ./...
- name: Test (umask 002)
if: runner.os != 'Windows'
run: go test -ldflags="-X github.com/twpayne/chezmoi/internal/chezmoitest.umaskStr=0o002" -race ./...
- name: Test
if: runner.os == 'Windows'
run: go test -race ./...
test-release:
runs-on: ubuntu-18.04
steps:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install musl-tools snapcraft
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.0
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --skip-publish --snapshot
- name: Test release
run: |
# verify that version information is embedded correctly
file ./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi | tee /dev/stderr | grep -q "dynamically linked"
file ./dist/chezmoi-cgo-musl_linux_amd64/chezmoi | tee /dev/stderr | grep -q "statically linked"
./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2"
./dist/chezmoi-cgo-musl_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2"
./dist/chezmoi-nocgo_linux_386/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v2"
- name: Upload artifact chezmoi-linux-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi-linux-amd64
path: dist/chezmoi-cgo-glibc_linux_amd64/chezmoi
- name: Upload artifact chezmoi-linux-musl-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi-linux-musl-amd64
path: dist/chezmoi-cgo-musl_linux_amd64/chezmoi
- name: Upload artifact chezmoi-darwin-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi-darwin-amd64
path: dist/chezmoi-nocgo_darwin_amd64/chezmoi
- name: Upload artifact chezmoi-darwin-arm64
uses: actions/upload-artifact@v2
with:
name: chezmoi-darwin-arm64
path: dist/chezmoi-nocgo_darwin_arm64/chezmoi
- name: Upload artifact chezmoi-windows-amd64.exe
uses: actions/upload-artifact@v2
with:
name: chezmoi-windows-amd64.exe
path: dist/chezmoi-nocgo_windows_amd64/chezmoi.exe
generate:
runs-on: ubuntu-18.04
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.7
- name: Checkout
uses: actions/checkout@v2
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate
run: |
go generate
git diff --exit-code
lint:
runs-on: ubuntu-18.04
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.7
- name: Checkout
uses: actions/checkout@v2
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41.1
- name: ShellCheck
uses: ludeeus/action-shellcheck@1.1.0
with:
scandir: ./assets/scripts
- name: Whitespace
run: go run ./internal/cmds/lint-whitespace
- name: Typos
run: |
go install github.com/twpayne/findtypos@latest
findtypos chezmoi .
release:
if: startsWith(github.ref, 'refs/tags/')
needs:
- generate
- lint
- test
- test-release
runs-on: ubuntu-18.04
steps:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get -yq --no-install-suggests --no-install-recommends install musl-tools snapcraft
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.7
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Snapcraft login
env:
SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }}
run: |
snapcraft login --with <(echo "$SNAPCRAFT_LOGIN" | base64 -d)
- name: Release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
# The following is needed because chezmoi upgrade and
# assets/scripts/install.sh have inconsistently looked for
# chezmoi_${VERSION}_checksums.txt and checksums.txt. To ensure
# compatibility with all versions, upload checksums.txt as well.
- name: Upload checksums.txt
run: |
VERSION=${GITHUB_REF##*/v}
cp dist/chezmoi_${VERSION}_checksums.txt dist/checksums.txt
gh release upload v${VERSION} dist/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}