-
Notifications
You must be signed in to change notification settings - Fork 409
357 lines (306 loc) · 12 KB
/
release.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
name: Release
on:
# Trigger the workflow on the new 'v*' tag created
push:
tags:
- "v*"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target: ["linux-static", "linux-arm-static"]
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=
substituters = https://cache.nixos.org/ https://cache.iog.io https://cache.zw3rk.com
- uses: cachix/cachix-action@v14
with:
name: hadolint
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
pushFilter: '(-source$|-config$|-hadolint-root$|hadolint-gitFiles|git-ls-files|hadolint-exe-hadolint-x86_64-unknown-linux-musl-|hadolint-exe-hadolint-aarch64-unknown-linux-musl-|hadolint-lib-hadolint-x86_64-unknown-linux-musl-|hadolint-lib-hadolint-aarch64-unknown-linux-musl-)'
- name: Build
run: |
nix-build release.nix -A "${{matrix.target}}" -j3
- name: Set binary ARCH
id: build-opts
run: |
if [ "${{ matrix.target }}" = 'linux-static' ]; then
echo ::set-output name=arch::amd64
else
echo ::set-output name=arch::arm64
fi
- name: Move binary
run: |
sudo cp result/bin/hadolint hadolint
sudo chmod 777 hadolint
- if: matrix.target == 'linux-static'
name: Compress binary
uses: svenstaro/upx-action@2.2.0
with:
file: hadolint
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: hadolint-Linux-${{steps.build-opts.outputs.arch}}
path: hadolint
retention-days: 3
docker:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
target: ["amd64", "arm64"]
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: hadolint-Linux-${{matrix.target}}
path: ${{matrix.target}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_IO_REGISTRY_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker Image Scratch
uses: docker/build-push-action@v4
with:
context: ${{matrix.target}}
file: docker/Dockerfile
platforms: linux/${{matrix.target}}
target: base
push: true
tags: |
ghcr.io/hadolint/hadolint:${{github.sha}}-${{matrix.target}}
hadolint/hadolint:${{github.sha}}-${{matrix.target}}
- name: Push Docker Image Debian
uses: docker/build-push-action@v4
with:
context: ${{matrix.target}}
file: docker/Dockerfile
platforms: linux/${{matrix.target}}
target: debian
push: true
tags: |
ghcr.io/hadolint/hadolint:${{github.sha}}-debian-${{matrix.target}}
hadolint/hadolint:${{github.sha}}-debian-${{matrix.target}}
- name: Push Docker Image Alpine
uses: docker/build-push-action@v4
with:
context: ${{matrix.target}}
file: docker/Dockerfile
platforms: linux/${{matrix.target}}
target: alpine
push: true
tags: |
ghcr.io/hadolint/hadolint:${{github.sha}}-alpine-${{matrix.target}}
hadolint/hadolint:${{github.sha}}-alpine-${{matrix.target}}
docker-release:
needs: docker
runs-on: ubuntu-latest
strategy:
matrix:
distro: ["scratch", "alpine", "debian"]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_IO_REGISTRY_TOKEN }}
- name: Set target and tag
id: build-opts
run: |
if [ "${{ matrix.distro }}" = 'scratch' ]; then
echo ::set-output name=target::${{github.sha}}
echo ::set-output name=latest::latest
echo ::set-output name=tag::"${GITHUB_REF/refs\/tags\/v/}"
else
echo ::set-output name=target::${{github.sha}}-${{matrix.distro}}
echo ::set-output name=latest::"latest-${{ matrix.distro }}"
echo ::set-output name=tag::"${GITHUB_REF/refs\/tags\/v/}-${{ matrix.distro }}"
fi
- name: Push Docker Images
run: |
docker pull ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64
docker pull ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker pull hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64
docker pull hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest create \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.latest }} \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64 \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest push ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.latest }}
docker manifest create \
hadolint/hadolint:${{ steps.build-opts.outputs.latest }} \
hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64 \
hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest push hadolint/hadolint:${{ steps.build-opts.outputs.latest }}
docker manifest create \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.tag }} \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64 \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest push ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.tag }}
docker manifest create \
hadolint/hadolint:${{ steps.build-opts.outputs.tag }} \
hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64 \
hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest push hadolint/hadolint:${{ steps.build-opts.outputs.tag }}
docker manifest create \
ghcr.io/hadolint/hadolint:v${{ steps.build-opts.outputs.tag }} \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64 \
ghcr.io/hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest push ghcr.io/hadolint/hadolint:v${{ steps.build-opts.outputs.tag }}
docker manifest create \
hadolint/hadolint:v${{ steps.build-opts.outputs.tag }} \
hadolint/hadolint:${{ steps.build-opts.outputs.target }}-amd64 \
hadolint/hadolint:${{ steps.build-opts.outputs.target }}-arm64
docker manifest push hadolint/hadolint:v${{ steps.build-opts.outputs.tag }}
os-binaries:
name: ${{ matrix.os }} / ${{ github.ref }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
- os: macos-14
- os: windows-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set tag name
uses: little-core-labs/get-git-tag@v3.0.2
id: tag
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: Setup Haskell
id: setup-haskell-cabal
uses: haskell-actions/setup@v2
with:
ghc-version: 9.8
- name: Freeze
run: cabal freeze
- name: Cache store
uses: actions/cache@v4
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
- name: Build binary
run: |
mkdir dist
cabal install exe:hadolint --install-method=copy --overwrite-policy=always --installdir=dist --ghc-options=-fPIC
- if: matrix.os == 'windows-latest'
name: Set extension to .exe on Windows
uses: allenevans/set-env@v3.0.0
with:
EXT: '.exe'
- name: Set binary OS name
uses: allenevans/set-env@v3.0.0
with:
BINARY_OS: ${{ runner.os }}
- name: Set binary Arch name
uses: allenevans/set-env@v3.0.0
with:
ARCH: 'x86_64'
- if: (matrix.os == 'macos-13') || (matrix.os == 'macos-14')
name: Set binary OS name on Macos
uses: allenevans/set-env@v3.0.0
with:
BINARY_OS: 'Darwin'
- if: matrix.os == 'macos-14'
name: Set binary ARCH name for apple silicon
uses: allenevans/set-env@v3.0.0
with:
ARCH: 'arm64'
- name: Set binary path name
uses: allenevans/set-env@v3.0.0
with:
BINARY_PATH: ./dist/hadolint${{ env.EXT }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: hadolint-${{ env.BINARY_OS }}-${{env.ARCH}}${{ env.EXT }}
path: ${{ env.BINARY_PATH }}
retention-days: 3
release:
needs: [docker-release, os-binaries]
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Download Linux x86
uses: actions/download-artifact@v4
with:
name: hadolint-Linux-amd64
path: artifacts/hadolint-Linux-x86_64
- name: Download Linux arm64
uses: actions/download-artifact@v4
with:
name: hadolint-Linux-arm64
path: artifacts/hadolint-Linux-arm64
- name: Download Macos x86
uses: actions/download-artifact@v4
with:
name: hadolint-Darwin-x86_64
path: artifacts/hadolint-Darwin-x86_64
- name: Download Macos arm
uses: actions/download-artifact@v4
with:
name: hadolint-Darwin-arm64
path: artifacts/hadolint-Darwin-arm64
- name: Download Windows x86
uses: actions/download-artifact@v4
with:
name: hadolint-Windows-x86_64.exe
path: artifacts/hadolint-Windows-x86_64.exe
- name: Rename and Checksum
run: |
mv artifacts/hadolint-Linux-x86_64/hadolint hadolint-Linux-x86_64
mv artifacts/hadolint-Linux-arm64/hadolint hadolint-Linux-arm64
mv artifacts/hadolint-Darwin-x86_64/hadolint hadolint-Darwin-x86_64
mv artifacts/hadolint-Darwin-arm64/hadolint hadolint-Darwin-arm64
mv artifacts/hadolint-Windows-x86_64.exe/hadolint.exe hadolint-Windows-x86_64.exe
sha256sum -b hadolint-Linux-x86_64 > hadolint-Linux-x86_64.sha256
sha256sum -b hadolint-Linux-arm64 > hadolint-Linux-arm64.sha256
sha256sum -b hadolint-Darwin-x86_64 > hadolint-Darwin-x86_64.sha256
sha256sum -b hadolint-Darwin-arm64 > hadolint-Darwin-arm64.sha256
sha256sum -b hadolint-Windows-x86_64.exe > hadolint-Windows-x86_64.exe.sha256
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: |
hadolint-Linux-x86_64
hadolint-Linux-x86_64.sha256
hadolint-Linux-arm64
hadolint-Linux-arm64.sha256
hadolint-Darwin-x86_64
hadolint-Darwin-x86_64.sha256
hadolint-Darwin-arm64
hadolint-Darwin-arm64.sha256
hadolint-Windows-x86_64.exe
hadolint-Windows-x86_64.exe.sha256