-
-
Notifications
You must be signed in to change notification settings - Fork 29
192 lines (162 loc) · 5.41 KB
/
build.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
name: Build
env:
DOCKER_IMAGE: cardanosolutions/kupo
on:
pull_request:
branches: [ "master" ]
push:
branches: [ "master", "release/v*" ]
tags: [ "*.*.*" ]
jobs:
build:
strategy:
matrix:
os: [ linux ]
arch: [ x86_64, aarch64 ]
compiler: [ ghc963 ]
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-latest' || 'buildjet-4vcpu-ubuntu-2204-arm' }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: 🧰 Install dependencies
shell: sh
run: |
sudo apt update
sudo apt install -y pandoc
- name: ❄️ Install Nix
uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.zw3rk.com/ https://cache.nixos.org/
nix_path: nixpkgs=channel:nixos-unstable
- name: 🧊 Prepare Cache
shell: bash
run: |
make configure
- name: 💾 Cache
uses: actions/cache@v3
with:
path: |
~/.cabal-static/packages
~/.cabal-static/store
key: cabal-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
cabal-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}
- name: 🔨 Build
run: |
make
env:
GIT_SHA: ${{ github.sha }}
- name: 🔎 Verify
run: |
./dist/bin/kupo --version
./dist/bin/kupo +RTS --info -RTS
- name: 📎 Upload Artifact
uses: actions/upload-artifact@v3
with:
name: kupo-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }}
path: |
dist/bin
dist/share
docker:
needs: [ build ]
strategy:
matrix:
os: [ linux ]
arch: [ x86_64, aarch64 ]
runs-on: ${{ matrix.os == 'linux' && 'ubuntu-latest' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{version}}
- name: hadolint
uses: hadolint/[email protected]
with:
dockerfile: "./Dockerfile"
failure-threshold: warning
ignore: DL3059, SC2086, DL3029
- 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: Download
uses: actions/download-artifact@v3
with:
name: kupo-${{ github.sha }}-${{ matrix.arch }}-${{ matrix.os }}
- name: Build and push (latest)
if: ${{ github.event_name == 'push' }}
id: build
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{ matrix.os }}/${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
target: kupo
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:latest
cache-to: type=inline
outputs: type=image,name=${{ env.DOCKER_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 ]
runs-on: ubuntu-latest
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: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{version}}
- name: Login to DockerHub
if: ${{ github.event_name == 'push' && steps.meta.outputs.tags != '' }}
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' && steps.meta.outputs.tags != '' }}
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKER_IMAGE }}@sha256:%s ' *)
- name: Inspect image
if: ${{ github.event_name == 'push' && steps.meta.outputs.tags != '' }}
run: |
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}