-
Notifications
You must be signed in to change notification settings - Fork 97
269 lines (262 loc) · 9.49 KB
/
release.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
name: Release
on:
push:
tags:
- v*
branches:
- "1609-release-standard-images"
jobs:
get-core-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
sudo apt update && sudo apt install -y jq
- id: set-matrix
run: |
content=`cat .github/flavors.json | jq 'map(select(.frameworkonly != "true"))'`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=matrix::{\"include\": $content }"
# The matrix for standard (provider) images
get-standard-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: Luet-lab/luet-install-action@v1
with:
repository: quay.io/kairos/packages
#TODO: Find a better solution
packages: utils/earthly
- run: |
git fetch --prune --unshallow
sudo apt update && sudo apt install -y jq
- id: set-matrix
run: |
# Construct an array like this from the found versions:
luet --config framework-profile.yaml search -o json k8s/k3s | jq '.packages | map(.version)' > k3s_versions.json
content=$(jq -s '. | combinations | .[0] + {"k3s_version": .[1]} | select(.frameworkonly != "true")' .github/flavors.json k3s_versions.json)
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=matrix::{\"include\": $content }"
get-framework-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- id: set-matrix
run: |
content=`cat .github/flavors.json`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=matrix::{\"include\": $content }"
build-framework:
runs-on: self-hosted
needs:
- get-framework-matrix
permissions:
id-token: write # OIDC support
contents: write
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-framework-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Install Cosign
uses: sigstore/cosign-installer@main
- name: Install earthly
uses: Luet-lab/luet-install-action@v1
with:
repository: quay.io/kairos/packages
packages: utils/earthly
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Build 🔧
env:
FLAVOR: ${{ matrix.flavor }}
IMAGE: quay.io/kairos/framework
run: |
# Configure earthly to use the docker mirror in CI
# https://docs.earthly.dev/ci-integration/pull-through-cache#configuring-earthly-to-use-the-cache
mkdir -p ~/.earthly/
cat << EOF > ~/.earthly/config.yml
global:
buildkit_additional_config: |
[registry."docker.io"]
mirrors = ["registry.docker-mirror.svc.cluster.local:5000"]
[registry."registry.docker-mirror.svc.cluster.local:5000"]
insecure = true
http = true
EOF
export TAG=${GITHUB_REF##*/}
earthly +build-framework-image --FLAVOR=${FLAVOR}
- name: Push to quay
env:
COSIGN_YES: true
if: startsWith(github.ref, 'refs/tags/')
run: |
export TAG=${GITHUB_REF##*/}_${{ matrix.flavor }}
export IMAGE="quay.io/kairos/framework"
docker push "$IMAGE:$TAG" # Otherwise .RepoDigests will be empty for some reason
cosign sign $(docker image inspect --format='{{index .RepoDigests 0}}' "$IMAGE:$TAG")
build-core:
runs-on: ubuntu-latest
needs:
- get-core-matrix
permissions:
id-token: write # OIDC support
contents: write
actions: read
security-events: write
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-core-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: setup-docker
uses: docker-practice/actions-setup-docker@master
- name: Install Cosign
uses: sigstore/cosign-installer@main
- name: Release space from worker
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Install earthly
uses: Luet-lab/luet-install-action@v1
with:
repository: quay.io/kairos/packages
packages: utils/earthly
- name: Build 🔧
env:
FLAVOR: ${{ matrix.flavor }}
run: |
earthly +all --VARIANT=core --FLAVOR=$FLAVOR
sudo mv build release
- name: Push to quay
env:
COSIGN_YES: true
if: startsWith(github.ref, 'refs/tags/')
run: |
export IMAGE=$(cat release/IMAGE)
docker push "$IMAGE"
image_ref=$(docker image inspect --format='{{index .RepoDigests 0}}' "$IMAGE")
spdx=$(ls release/*.spdx.json)
cosign attach sbom --sbom $spdx $image_ref
cosign sign $image_ref --attachment sbom
# in-toto attestation
cosign attest --type spdx --predicate $spdx $image_ref
- name: Sign ISO sha files
env:
COSIGN_YES: true
run: |
sudo chmod -R 777 release
filename=$(ls release/*.iso.sha256)
cosign sign-blob --yes --output-certificate="release/${filename}.pem" \
--output-signature="release/${filename}.sig" \
"release/${filename}"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
release/*
- name: Prepare sarif files 🔧
run: |
mkdir sarif
mv release/*.sarif sarif/
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: startsWith(github.ref, 'refs/tags/')
with:
sarif_file: 'sarif'
category: ${{ matrix.flavor }}
build-core-uki:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Install earthly
uses: Luet-lab/luet-install-action@v1
with:
repository: quay.io/kairos/packages
packages: utils/earthly
- name: Build uki image 🔧
run: |
# Do fedora as its the smaller uki possible
earthly +uki --VARIANT=core --FLAVOR=fedora
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
build/*.efi
build-standard:
runs-on: ubuntu-latest
needs:
- get-standard-matrix
permissions:
id-token: write # OIDC support
contents: write
actions: read
security-events: write
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-standard-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: setup-docker
uses: docker-practice/actions-setup-docker@master
- name: Install Cosign
uses: sigstore/cosign-installer@main
- name: Release space from worker
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
- name: Login to Quay Registry
run: echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
- name: Build 🔧
run: |
./earthly.sh +all -VARIANT=standard -K3S_VERSION=${{ matrix.k3s_version }} -FLAVOR=${{ matrix.flavor }}
sudo mv build release
- name: Push to quay
if: startsWith(github.ref, 'refs/tags/')
env:
COSIGN_YES: true
run: |
# TODO: Stick to the old naming
IMAGE=$(cat release/IMAGE)
docker push "$IMAGE"
cosign sign $(docker image inspect --format='{{index .RepoDigests 0}}' "$IMAGE")
sudo rm -rf release/IMAGE release/VERSION
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
release/*