-
-
Notifications
You must be signed in to change notification settings - Fork 91
644 lines (565 loc) · 34 KB
/
continuous-integration.yaml
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
name: Continuous Integration
on:
workflow_dispatch:
pull_request:
branches: [ "master" ]
push:
branches: [ "master", "v*.*" ]
tags: [ "*.*.*" ]
jobs:
# █████████ ███████████ ███ ████ █████
# ███░░░░░███ ░░███░░░░░███ ░░░ ░░███ ░░███
# ░███ ░░░ ██████ ████████ █████ █████ ██████ ████████ ░███ ░███ █████ ████ ████ ░███ ███████
# ░░█████████ ███░░███░░███░░███░░███ ░░███ ███░░███░░███░░███ ░██████████ ░░███ ░███ ░░███ ░███ ███░░███
# ░░░░░░░░███░███████ ░███ ░░░ ░███ ░███ ░███████ ░███ ░░░ ░███░░░░░███ ░███ ░███ ░███ ░███ ░███ ░███
# ███ ░███░███░░░ ░███ ░░███ ███ ░███░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███
# ░░█████████ ░░██████ █████ ░░█████ ░░██████ █████ ███████████ ░░████████ █████ █████░░████████
# ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░
server_build:
strategy:
matrix:
os: [ linux ]
arch: [ x86_64, aarch64 ]
compiler: [ ghc94 ]
devx-version: [ 54ea65610338600bd4c4afd04b0b6ff612988fd4 ]
runs-on: ${{ matrix.os == 'linux' && matrix.arch == 'aarch64' && 'buildjet-16vcpu-ubuntu-2204-arm' || 'ubuntu-22.04' }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: 📝 Version
id: version
shell: bash
working-directory: server
run: |
VERSION=$(cat package.yaml | grep "version:" | sed "s/[^0-9]*\([0-9]\)\(.[0-9].[0-9]\)*/\1\2/")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install Nix with good defaults
uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
name: cardano-ogmios
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: ❄️ Prepare cache (x86_64)
if: ${{ matrix.arch == 'x86_64' }}
working-directory: server
run: |
nix develop github:input-output-hk/devx/${{ matrix.devx-version}}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cat /nix/store/vd865r55pdbndjwh994h90m35qq77x44-cabal.project.local >> cabal.project.local && cabal update && cabal freeze"
- name: ❄️ Prepare cache (aarch64)
if: ${{ matrix.arch == 'aarch64' }}
working-directory: server
run: |
nix develop github:input-output-hk/devx/${{ matrix.devx-version}}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cat /nix/store/hviyb5sciblcyr5fc3vsqcwmfh1nz69w-cabal.project.local >> cabal.project.local && cabal update && cabal freeze"
- name: 💾 Download Cache
uses: actions/cache/restore@v3
with:
path: |
~/.cabal-static/packages
~/.cabal-static/store
server/dist-newstyle
key: cabal-cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ hashFiles('server/cabal.project.freeze') }}
restore-keys: |
cabal-cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.compiler }}
- name: 🔨 Dependencies
working-directory: server
run: |
nix develop github:input-output-hk/devx/${{ matrix.devx-version }}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cabal build --enable-executable-static --only-dependencies ogmios:lib:ogmios"
env:
GIT_SHA: ${{ github.sha }}
- name: 💾 Save Cache
uses: actions/cache/save@v3
with:
path: |
~/.cabal-static/packages
~/.cabal-static/store
server/dist-newstyle
key: cabal-cache-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ hashFiles('server/cabal.project.freeze') }}
- name: 🔨 Build
working-directory: server
run: |
nix develop github:input-output-hk/devx/${{ matrix.devx-version }}#${{ matrix.compiler }}-static-minimal-iog --no-write-lock-file --refresh --command bash -c "cabal build --enable-executable-static ogmios:exe:ogmios"
env:
GIT_SHA: ${{ github.sha }}
- name: 📦 Package
run: |
mkdir -p bin
cp ./server/dist-newstyle/build/${{ matrix.arch }}-${{ matrix.os }}/ghc-${{ matrix.compiler == 'ghc94' && '9.4.8' }}/ogmios-${{ steps.version.outputs.version }}/x/ogmios/build/ogmios/ogmios ./bin/ogmios
mkdir -p share && chmod +w share
mkdir -p share/zsh/site-functions
./bin/ogmios --zsh-completion-script ogmios > ./share/zsh/site-functions/_ogmios
mkdir -p share/bash-completion/completions
./bin/ogmios --bash-completion-script ogmios > ./share/bash-completion/completions/ogmios
chmod -w share
- name: 🔬 Version Sanity Check
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}
id: version-check
shell: bash
run: |
OUTPUT=$(./bin/ogmios --version)
if [[ $CABAL == "0" ]]; then
VERSION="nightly"
else
VERSION="v$CABAL"
fi
if [[ $GITHUB_REF == "refs/tags"* ]]; then
TAG=$(echo ${GITHUB_REF/refs\/tags\/} | sed "s/^.*\(v[0-9].[0-9].[0-9]\).*$/\1/")
else
TAG="nightly"
fi
echo "git: $TAG <-- ${GITHUB_REF/refs\/tags\/}"
echo "cabal: $VERSION <-- $CABAL"
echo "bin: $OUTPUT"
echo ""
if [[ $OUTPUT == $TAG* ]] && [[ $OUTPUT == $VERSION* ]]; then
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Ok."
exit 0
else
echo "x inconsistent versions"
exit 1
fi
env:
CABAL: ${{ steps.version.outputs.version }}
- name: 📎 Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }}
path: |
bin
share
# █████████ █████ ███ █████
# ███░░░░░███ ░░███ ░░░ ░░███
# ░███ ░░░ ██████ ████████ █████ █████ ██████ ████████ ░███ ████ ████████ ███████
# ░░█████████ ███░░███░░███░░███░░███ ░░███ ███░░███░░███░░███ ░███ ░░███ ░░███░░███ ░░░███░
# ░░░░░░░░███░███████ ░███ ░░░ ░███ ░███ ░███████ ░███ ░░░ ░███ ░███ ░███ ░███ ░███
# ███ ░███░███░░░ ░███ ░░███ ███ ░███░░░ ░███ ░███ █ ░███ ░███ ░███ ░███ ███
# ░░█████████ ░░██████ █████ ░░█████ ░░██████ █████ ███████████ █████ ████ █████ ░░█████
# ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░
server_lint:
strategy:
matrix:
os: [ ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
steps:
- name: 📥 Checkout repository
uses: actions/[email protected]
with:
submodules: true
- name: 🔬 hlint
working-directory: server
shell: bash
env:
PACKAGE: hlint
REPOSITORY: ndmitchell/hlint
PLATFORM: x86_64-linux
RELEASE: v3.6.1
VERSION: 3.6.1
run: |
curl -sSL https://raw.github.com/cardanosolutions/ogmios/master/scripts/exec-from-github.sh | sh -s src test app -h .hlint.yaml
- name: 🧐 stylish-haskell
working-directory: server
shell: bash
env:
PACKAGE: stylish-haskell
REPOSITORY: jaspervdj/stylish-haskell
PLATFORM: linux-x86_64
RELEASE: v0.14.5.0
VERSION: v0.14.5.0
run: |
curl -sSL https://raw.github.com/cardanosolutions/ogmios/master/scripts/exec-from-github.sh | sh -s $(find src test app -type f -name '*.hs' ! -path '*.stack-work*') -i -c .stylish-haskell.yaml
if [ -z "$(git status --porcelain)" ]; then
echo "No style errors detected."
else
echo "Style errors detected:"
git diff
exit 1
fi
#
# ███████████ █████████ ███ █████ █████████ ████ ███ █████
# ░█░░░███░░░█ ███░░░░░███ ░░░ ░░███ ███░░░░░███░░███ ░░░ ░░███
# ░ ░███ ░ █████ ████ ████████ ██████ ░███ ░░░ ██████ ████████ ████ ████████ ███████ ███ ░░░ ░███ ████ ██████ ████████ ███████
# ░███ ░░███ ░███ ░░███░░███ ███░░███░░█████████ ███░░███░░███░░███░░███ ░░███░░███░░░███░ ░███ ░███ ░░███ ███░░███░░███░░███ ░░░███░
# ░███ ░███ ░███ ░███ ░███░███████ ░░░░░░░░███░███ ░░░ ░███ ░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███████ ░███ ░███ ░███
# ░███ ░███ ░███ ░███ ░███░███░░░ ███ ░███░███ ███ ░███ ░███ ░███ ░███ ░███ ███ ░░███ ███ ░███ ░███ ░███░░░ ░███ ░███ ░███ ███
# █████ ░░███████ ░███████ ░░██████ ░░█████████ ░░██████ █████ █████ ░███████ ░░█████ ░░█████████ █████ █████░░██████ ████ █████ ░░█████
# ░░░░░ ░░░░░███ ░███░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░
# ███ ░███ ░███ ░███
# ░░██████ █████ █████
# ░░░░░░ ░░░░░ ░░░░░
clients_TypeScript:
needs: [server_build]
strategy:
matrix:
os: [ linux ]
arch: [ x86_64 ]
network: [ preview ]
cardano-node: [ 10.1.2 ]
runs-on: ${{ matrix.os == 'linux' && 'ubuntu-22.04' }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: ⌚ Get Date/Time
id: date-time
shell: bash
run: |
echo "::set-output name=value::$(/bin/date -u "+%Y%m%d-%H%M%S")"
- name: 🧰 Setup Node.js
uses: actions/[email protected]
with:
node-version: lts/Gallium
- name: 🔨 Build
working-directory: clients/TypeScript
run: |
yarn install --frozen-lockfile --non-interactive --logevel=error
yarn build
yarn lint
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }}
path: server
- name: 💾 Cache cardano-node DB
id: cache
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/db-${{ matrix.network }}
key: cardano-node-ogmios-${{ matrix.network }}-${{ steps.date-time.outputs.value }}
restore-keys: |
cardano-node-ogmios-${{ matrix.network }}-
- name: 🔬 Test
if: ${{ matrix.network == 'preview' }}
working-directory: clients/TypeScript
shell: bash
env:
CONFDIR: /home/runner/work/ogmios/ogmios/server/config/network/${{ matrix.network }}
run: |
chmod +x ../../server/bin/ogmios
sudo ../../server/bin/ogmios --port 1337 --log-level error --node-socket ${{ runner.temp }}/ipc/node.socket --node-config $CONFDIR/cardano-node/config.json &
docker pull ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }}
docker run -d --name cardano-node \
-v ${{ runner.temp }}/db-${{ matrix.network }}:/db \
-v ${{ runner.temp }}/ipc:/ipc \
-v $CONFDIR/cardano-node:/config \
-v $CONFDIR/genesis:/genesis \
ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }} run --config /config/config.json --database-path /db --socket-path /ipc/node.socket --topology /config/topology.json
../../scripts/wait-for-sync.sh 1337 1 "docker logs --since 10s cardano-node"
yarn test
docker stop cardano-node
docker rm cardano-node
#
# ███████████ █████████ ███ █████ ███████████ ██████████ ███████████ █████
# ░█░░░███░░░█ ███░░░░░███ ░░░ ░░███ ░░███░░░░░███ ░░███░░░░░█░░███░░░░░███░░███
# ░ ░███ ░ █████ ████ ████████ ██████ ░███ ░░░ ██████ ████████ ████ ████████ ███████ ░███ ░███ ░███ █ ░ ░███ ░███ ░███
# ░███ ░░███ ░███ ░░███░░███ ███░░███░░█████████ ███░░███░░███░░███░░███ ░░███░░███░░░███░ ░██████████ ░██████ ░██████████ ░███
# ░███ ░███ ░███ ░███ ░███░███████ ░░░░░░░░███░███ ░░░ ░███ ░░░ ░███ ░███ ░███ ░███ ░███░░░░░███ ░███░░█ ░███░░░░░░ ░███
# ░███ ░███ ░███ ░███ ░███░███░░░ ███ ░███░███ ███ ░███ ░███ ░███ ░███ ░███ ███ ░███ ░███ ░███ ░ █ ░███ ░███ █
# █████ ░░███████ ░███████ ░░██████ ░░█████████ ░░██████ █████ █████ ░███████ ░░█████ █████ █████ ██████████ █████ ███████████
# ░░░░░ ░░░░░███ ░███░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░░░░░░░
# ███ ░███ ░███ ░███
# ░░██████ █████ █████
# ░░░░░░ ░░░░░ ░░░░░
clients_TypeScript_repl:
if: ${{ github.event_name == 'push' }}
runs-on: ${{ matrix.os }}
needs: [clients_TypeScript]
strategy:
matrix:
os: [ ubuntu-22.04 ]
target: [linux,macos,win.exe]
steps:
- name: 📥 Checkout repository
uses: actions/[email protected]
- name: 🧰 Setup Node.js
uses: actions/[email protected]
with:
node-version: lts/Gallium
- name: 📦 Package REPL
working-directory: clients/TypeScript
run: |
yarn install --frozen-lockfile --non-interactive --logevel=error
yarn repl:pkg
- name: 📎 Upload REPL exe
uses: actions/[email protected]
with:
name: cardano-ogmios-repl-${{ matrix.target }}-${{ github.sha }}
path: clients/TypeScript/packages/repl/build/cardano-ogmios-repl-${{ matrix.target }}
# ███████████ █████████ ███ █████ ██████ █████ ███████████ ██████ ██████
# ░█░░░███░░░█ ███░░░░░███ ░░░ ░░███ ░░██████ ░░███ ░░███░░░░░███░░██████ ██████
# ░ ░███ ░ █████ ████ ████████ ██████ ░███ ░░░ ██████ ████████ ████ ████████ ███████ ░███░███ ░███ ░███ ░███ ░███░█████░███
# ░███ ░░███ ░███ ░░███░░███ ███░░███░░█████████ ███░░███░░███░░███░░███ ░░███░░███░░░███░ ░███░░███░███ ░██████████ ░███░░███ ░███
# ░███ ░███ ░███ ░███ ░███░███████ ░░░░░░░░███░███ ░░░ ░███ ░░░ ░███ ░███ ░███ ░███ ░███ ░░██████ ░███░░░░░░ ░███ ░░░ ░███
# ░███ ░███ ░███ ░███ ░███░███░░░ ███ ░███░███ ███ ░███ ░███ ░███ ░███ ░███ ███ ░███ ░░█████ ░███ ░███ ░███
# █████ ░░███████ ░███████ ░░██████ ░░█████████ ░░██████ █████ █████ ░███████ ░░█████ █████ ░░█████ █████ █████ █████
# ░░░░░ ░░░░░███ ░███░░░ ░░░░░░ ░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
# ███ ░███ ░███ ░███
# ░░██████ █████ █████
# ░░░░░░ ░░░░░ ░░░░░
clients_TypeScript_npm:
if: ${{ github.event_name == 'push' }}
runs-on: ${{ matrix.os }}
needs: [clients_TypeScript]
strategy:
matrix:
os: [ ubuntu-22.04 ]
package: [ schema, client, repl ]
steps:
- name: 📥 Checkout repository
uses: actions/[email protected]
- name: 🧰 Setup Node.js
uses: actions/[email protected]
with:
node-version: lts/Gallium
- name: 📦 Pack
working-directory: clients/TypeScript
run: |
yarn install --frozen-lockfile --non-interactive --logevel=error
./scripts/pack.sh
- name: 📎 Upload npm packages
uses: actions/[email protected]
with:
name: cardano-ogmios-clients-ts-packages
path: |
clients/TypeScript/cardano-ogmios-client-${{ github.sha }}.tgz
clients/TypeScript/cardano-ogmios-schema-${{ github.sha }}.tgz
clients/TypeScript/cardano-ogmios-repl-${{ github.sha }}.tgz
- name: 📤 Publish client package to npm registry
if: ${{ startsWith(github.ref, 'refs/tags') }}
uses: JS-DevTools/npm-publish@v2
with:
package: clients/TypeScript/packages/${{ matrix.package }}/package.json
strategy: upgrade
token: ${{ secrets.NPM_TOKEN }}
# ██████████ ███████ █████████ █████ ████ ██████████ ███████████
# ░░███░░░░███ ███░░░░░███ ███░░░░░███░░███ ███░ ░░███░░░░░█░░███░░░░░███
# ░███ ░░███ ███ ░░███ ███ ░░░ ░███ ███ ░███ █ ░ ░███ ░███
# ░███ ░███░███ ░███░███ ░███████ ░██████ ░██████████
# ░███ ░███░███ ░███░███ ░███░░███ ░███░░█ ░███░░░░░███
# ░███ ███ ░░███ ███ ░░███ ███ ░███ ░░███ ░███ ░ █ ░███ ░███
# ██████████ ░░░███████░ ░░█████████ █████ ░░████ ██████████ █████ █████
# ░░░░░░░░░░ ░░░░░░░ ░░░░░░░░░ ░░░░░ ░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░
docker_combined:
needs: [ server_build ]
runs-on: ${{ matrix.os == 'linux' && 'ubuntu-22.04' }}
strategy:
matrix:
os: [ linux ]
target: [ cardano-node-ogmios ]
network: [ mainnet, preprod, preview, sanchonet ]
cardano-node: [ 10.1.2 ]
cardano-node-latest: [ 10.1.2 ]
arch: [ x86_64 ]
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: 🧰 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🧐 hadolint
uses: brpaz/[email protected]
with:
dockerfile: "./Dockerfile"
failure-threshold: warning
ignore: DL3029 DL3059
- name: 🐳 Login to DockerHub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: 📝 Base Variables
id: base-variables
run: |
echo "image=cardanosolutions/${{ matrix.target }}" >> $GITHUB_OUTPUT
- name: 📝 Tag Variables
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
id: tag-variables
run: |
echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }}
path: server
- name: "📸 :latest"
id: build
if: ${{ github.event_name == 'push' && matrix.network == 'mainnet' && github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v4
with:
build-args: |
NETWORK=${{ matrix.network }}
CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node-latest }}
context: .
push: true
tags: ${{ steps.base-variables.outputs.image }}:latest
target: ${{ matrix.target }}
platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest
cache-to: type=inline
- name: "📸 :latest-${{ matrix.network }}"
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v4
with:
build-args: |
NETWORK=${{ matrix.network }}
CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node-latest }}
context: .
push: true
tags: ${{ steps.base-variables.outputs.image }}:latest-${{ matrix.network }}
target: ${{ matrix.target }}
platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest-${{ matrix.network }}
cache-to: type=inline
- name: "🏷️ :v*.*.*"
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && matrix.network == 'mainnet' }}
uses: docker/build-push-action@v4
with:
build-args: |
NETWORK=${{ matrix.network }}
CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }}
context: .
push: true
tags: ${{ steps.base-variables.outputs.image }}:${{ steps.tag-variables.outputs.tag }}_${{ matrix.cardano-node }}
target: ${{ matrix.target }}
platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest
cache-to: type=inline
- name: "🏷️ :v*.*.*-${{ matrix.network }}"
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
uses: docker/build-push-action@v4
with:
build-args: |
NETWORK=${{ matrix.network }}
CARDANO_NODE_IMAGE=ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano-node }}
context: .
push: true
tags: ${{ steps.base-variables.outputs.image }}:${{ steps.tag-variables.outputs.tag }}_${{ matrix.cardano-node }}-${{ matrix.network }}
target: ${{ matrix.target }}
platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest-${{ matrix.network }}
cache-to: type=inline
docker_standalone:
needs: [ server_build ]
runs-on: ${{ matrix.os == 'linux' && 'ubuntu-22.04' }}
strategy:
matrix:
os: [ linux ]
target: [ ogmios ]
arch: [ x86_64, aarch64 ]
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: 🧰 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🧐 hadolint
uses: brpaz/[email protected]
with:
dockerfile: "./Dockerfile"
failure-threshold: warning
ignore: DL3029 DL3059
- name: 🐳 Login to DockerHub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: 📝 Base Variables
id: base-variables
run: |
echo "image=cardanosolutions/${{ matrix.target }}" >> $GITHUB_OUTPUT
- name: 📝 Tag Variables
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
id: tag-variables
run: |
echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: 📝 Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.base-variables.outputs.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{version}}
- name: 📥 Download
uses: actions/download-artifact@v3
with:
name: ogmios-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }}
path: server
- name: 📸 Build image
id: build
if: ${{ github.event_name == 'push' }}
uses: docker/build-push-action@v4
with:
context: .
target: ${{ matrix.target }}
platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
cache-from: type=registry,ref=${{ steps.base-variables.outputs.image }}:latest
cache-to: type=inline
outputs: type=image,name=${{ steps.base-variables.outputs.image }},push-by-digest=true,name-canonical=true,push=true
- name: 🔡 Export digest
if: ${{ github.event_name == 'push' }}
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: 💾 Upload digest
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
registry:
needs: [ docker_standalone ]
runs-on: ubuntu-22.04
strategy:
matrix:
target: [ ogmios ]
steps:
- name: 📥 Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
- name: 🧰 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 📝 Base Variables
id: base-variables
run: |
echo "image=cardanosolutions/${{ matrix.target }}" >> $GITHUB_OUTPUT
- name: 📝 Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.base-variables.outputs.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{version}}
- name: 🐳 Login to DockerHub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: 📦 Create manifest list and push
if: ${{ github.event_name == 'push' }}
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ steps.base-variables.outputs.image }}@sha256:%s ' *)
- name: 🧐 Inspect image
if: ${{ github.event_name == 'push' }}
run: |
docker buildx imagetools inspect ${{ steps.base-variables.outputs.image }}:${{ steps.meta.outputs.version }}