-
-
Notifications
You must be signed in to change notification settings - Fork 242
427 lines (388 loc) · 17.7 KB
/
build.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
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
name: Build Bazzite
on:
schedule:
- cron: "40 4 * * 1" # 4:40 utc monday
pull_request:
branches:
- testing
- unstable
paths-ignore:
- "**.md"
- "**.txt"
- "installer/**"
- "repo_content/**"
- "spec_files/**"
- "post_install_files/**"
- "press_kit/**"
- "docs/**"
- ".github/workflows/build_iso.yml"
push:
branches:
- testing
- unstable
paths-ignore:
- "**.md"
- "**.txt"
- "repo_content/**"
- "spec_files/**"
- "post_install_files/**"
- "press_kit/**"
- ".github/workflows/build_iso.yml"
merge_group:
workflow_dispatch:
inputs:
handwritten:
description: 'Small changelog:'
# Run with this periodically to analyze the image again
# As package drift will make the plan eventually non-ideal
# (existing users will have to redownload most of the image)
fresh-rechunk:
description: 'Clear rechunk history'
type: boolean
default: false
env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
push-ghcr:
name: Make
runs-on: ubuntu-24.04
continue-on-error: false
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
base_image_flavor: [main]
base_name: [bazzite, bazzite-deck, bazzite-nvidia]
base_image_name: [kinoite, silverblue]
target_image_flavor: [main, asus]
target_nvidia_flavor: [nvidia, nvidia-open]
fedora_version: [41]
include:
- fedora_version: 41
is_latest_version: true
is_stable_version: true
kernel_flavor: bazzite # must match a kernel_flavor from akmods repo
kernel_version: 6.11.5-310.bazzite.fc41.x86_64 # must match a cached version of the above flavor
exclude:
- base_name: bazzite
target_nvidia_flavor: nvidia
- base_name: bazzite-deck
target_nvidia_flavor: nvidia
steps:
- name: Define env.IMAGE_FLAVOR
run: |
if [[ "${{ matrix.base_name }}" == "bazzite-nvidia" ]]; then
if [[ "${{ matrix.target_image_flavor }}" == "main" ]]; then
echo "IMAGE_FLAVOR=${{ matrix.target_nvidia_flavor }}" >> $GITHUB_ENV
else
echo "IMAGE_FLAVOR=${{ format('{0}-{1}', matrix.target_image_flavor, matrix.target_nvidia_flavor) }}" >> $GITHUB_ENV
fi
else
echo "IMAGE_FLAVOR=${{ matrix.target_image_flavor }}" >> $GITHUB_ENV
fi
- name: Define env.IMAGE_NAME
run: |
DESKTOP=""
if [[ "${{ matrix.base_image_name }}" == "silverblue" ]]; then
DESKTOP="-gnome"
fi
if [[ "${{ matrix.base_name }}" == "bazzite-deck" ]]; then
if [[ "${{ matrix.target_image_flavor }}" == "asus" ]]; then
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-ally', '${DESKTOP}') }}" >> $GITHUB_ENV
else
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-deck', '${DESKTOP}') }}" >> $GITHUB_ENV
fi
else
if [[ "${{ env.IMAGE_FLAVOR }}" == "main" ]]; then
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite', '${DESKTOP}') }}" >> $GITHUB_ENV
else
echo "IMAGE_NAME=${{ format('{0}{1}-{2}', 'bazzite', '${DESKTOP}', env.IMAGE_FLAVOR) }}" >> $GITHUB_ENV
fi
fi
- name: Define env.SHA_HEAD_SHORT
run: |
echo "SHA_HEAD_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Verify main image
uses: EyeCantCU/cosign-action/[email protected]
with:
containers: ${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }}
pubkey: https://raw.githubusercontent.com/ublue-os/${{ matrix.base_image_flavor }}/main/cosign.pub
registry: ${{ env.IMAGE_REGISTRY }}
- name: Verify akmods image
uses: EyeCantCU/cosign-action/[email protected]
with:
containers: akmods:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}-${{ matrix.kernel_version }}
pubkey: https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
registry: ${{ env.IMAGE_REGISTRY }}
- name: Verify akmods-nvidia image
uses: EyeCantCU/cosign-action/[email protected]
with:
containers: akmods-${{ matrix.target_nvidia_flavor }}:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}-${{ matrix.kernel_version }}
pubkey: https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
registry: ${{ env.IMAGE_REGISTRY }}
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
uses: actions/checkout@v4
# Prepare offline documentation
- run: mkdir -p ${{ github.workspace }}/system_files/desktop/shared/usr/share/ublue-os/docs/html
continue-on-error: true
- name: Checkout docs repo
run: rm -r ${{ github.workspace }}/docs && git clone https://github.com/KyleGospo/docs.bazzite.gg.git ${{ github.workspace }}/docs
continue-on-error: true
- name: Build offline documentation
uses: ./.github/workflows/build_mkdocs
continue-on-error: true
with:
github_token: ${{ github.token }}
output_dir: ${{ github.workspace }}/system_files/desktop/shared/usr/share/ublue-os/docs/html
upload_github_page: "false"
- name: Check just syntax
uses: ublue-os/just-action@v2
- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v7
- name: Pull main, akmods, rechunk images
uses: Wandalen/[email protected]
with:
attempt_limit: 3
attempt_delay: 15000
command: |
# pull the base images used for FROM in Containerfile so
# we can retry on that unfortunately common failure case
sudo podman pull ${{ env.IMAGE_REGISTRY }}/${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }}
sudo podman pull ${{ env.IMAGE_REGISTRY }}/akmods:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}-${{ matrix.kernel_version }}
sudo podman pull ${{ env.IMAGE_REGISTRY }}/akmods-${{ matrix.target_nvidia_flavor }}:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}-${{ matrix.kernel_version }}
# Add rechunk as well to remove this source of failure
sudo podman pull ghcr.io/hhd-dev/rechunk:v1.0.1
- name: Get source versions
id: labels
uses: Wandalen/[email protected]
with:
attempt_limit: 3
attempt_delay: 15000
command: |
set -eo pipefail
skopeo inspect docker://${{ env.IMAGE_REGISTRY }}/${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }} > source.json
ver=$(jq -r '.Labels["org.opencontainers.image.version"]' source.json)
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
echo "inspected image version must not be empty or null"
exit 1
fi
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV
# Generate a primary version key that appears
# in KDE, rpm-ostree status, and github.
- name: Generate Version
id: generate-version
shell: bash
run: |
# Generate the primary version key that will be stored on os-release,
# shown on the bootloader, and used for the image tag.
UPSTREAM_TAG="${{ env.SOURCE_IMAGE_VERSION }}"
# Remove .0 suffix from upstream tag so we can add our own and
# the wrong one does not end up in the image.
UPSTREAM_TAG="${UPSTREAM_TAG%.*}"
FEDORA_VERSION="${{ matrix.fedora_version }}"
SHA_SHORT="${GITHUB_SHA::7}"
if [ -n "${{ github.event.pull_request.number }}" ]; then
VERSION="pr-${FEDORA_VERSION}-${{ github.event.pull_request.number }}"
PRETTY_VERSION="PR (${{ github.event.pull_request.number }}, ${UPSTREAM_TAG})"
elif [[ ${{ github.ref_name }} == "unstable" ]]; then
VERSION="unstable-${UPSTREAM_TAG}"
PRETTY_VERSION="Unstable (F${UPSTREAM_TAG}, #${SHA_SHORT})"
elif [[ ${{ github.ref_name }} == "testing" ]]; then
VERSION="testing-${UPSTREAM_TAG}"
PRETTY_VERSION="Testing (F${UPSTREAM_TAG}, #${SHA_SHORT})"
else
VERSION="${UPSTREAM_TAG}"
PRETTY_VERSION="Stable (F${UPSTREAM_TAG})"
fi
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
echo "pretty=${PRETTY_VERSION}" >> $GITHUB_OUTPUT
echo "Generated the following:"
cat $GITHUB_OUTPUT
# Build image using buildah and save it to raw-img
- name: Build Image
id: build_image
run: |
sudo buildah build \
--target ${{ matrix.base_name }} \
--build-arg IMAGE_NAME=${{ env.IMAGE_NAME }} \
--build-arg IMAGE_FLAVOR=${{ env.IMAGE_FLAVOR }} \
--build-arg NVIDIA_FLAVOR=${{ matrix.target_nvidia_flavor }} \
--build-arg IMAGE_VENDOR=${{ github.repository_owner }} \
--build-arg BASE_IMAGE_NAME=${{ matrix.base_image_name }} \
--build-arg BASE_IMAGE_FLAVOR=${{ matrix.base_image_flavor }} \
--build-arg FEDORA_VERSION=${{ matrix.fedora_version }} \
--build-arg KERNEL_FLAVOR=${{ matrix.kernel_flavor }} \
--build-arg KERNEL_VERSION=${{ matrix.kernel_version }} \
--build-arg IMAGE_BRANCH=${{ github.ref_name }} \
--build-arg SHA_HEAD_SHORT=${{ env.SHA_HEAD_SHORT }} \
--build-arg VERSION_TAG=${{ steps.generate-version.outputs.tag }} \
--build-arg VERSION_PRETTY="${{ steps.generate-version.outputs.pretty }}" \
--tag raw-img .
- name: Remove auxiliary images
# We are tight on space, need at least 2x for OSTree
run: |
sudo podman image rm ${{ env.IMAGE_REGISTRY }}/${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }}
sudo podman image rm ${{ env.IMAGE_REGISTRY }}/akmods:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}-${{ matrix.kernel_version }}
sudo podman image rm ${{ env.IMAGE_REGISTRY }}/akmods-${{ matrix.target_nvidia_flavor }}:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}-${{ matrix.kernel_version }}
# Generate the previous image reference used by the Rechunker
- name: Generate previous reference
id: generate-prev-ref
shell: bash
run: |
if [ "${{ github.event.inputs.fresh-rechunk }}" == "true" ]; then
IMAGEREF=""
else
IMAGEREF="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:stable"
fi
echo "ref=${IMAGEREF}" >> $GITHUB_OUTPUT
echo "Generated the following:"
cat $GITHUB_OUTPUT
- name: Check Secureboot
shell: bash
run: |
set -x
if [[ ! $(command -v sbverify) || ! $(command -v curl) || ! $(command -v openssl) ]]; then
sudo apt update
sudo apt install sbsigntool curl openssl
fi
TMP=$(sudo podman create raw-img bash)
sudo podman cp $TMP:/usr/lib/modules/${{ matrix.kernel_version }}/vmlinuz .
sudo podman rm $TMP
sudo chmod 666 vmlinuz # might not be needed
sbverify --list vmlinuz
curl --retry 3 -Lo kernel-sign.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key.der
curl --retry 3 -Lo akmods.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key_2.der
openssl x509 -in kernel-sign.der -out kernel-sign.crt
openssl x509 -in akmods.der -out akmods.crt
sbverify --cert kernel-sign.crt vmlinuz || exit 1
sbverify --cert akmods.crt vmlinuz || exit 1
# Reprocess raw-img using rechunker which will delete it
- name: Run Rechunker
id: rechunk
uses: hhd-dev/[email protected]
with:
rechunk: 'ghcr.io/hhd-dev/rechunk:v1.0.1'
ref: 'raw-img'
prev-ref: '${{ steps.generate-prev-ref.outputs.ref }}'
version: '${{ steps.generate-version.outputs.tag }}'
labels: |
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/ublue-os/bazzite/main/repo_content/logo.png
io.artifacthub.package.readme-url=https://docs.bazzite.gg
org.opencontainers.image.created=<timestamp>
org.opencontainers.image.description=Bazzite is a custom image built upon Fedora Atomic Desktops that brings the best of Linux gaming to all of your devices - including your favorite handheld.
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/ublue-os/bazzite
org.opencontainers.image.title=Bazzite
org.opencontainers.image.vendor=Universal Blue
org.opencontainers.image.url=https://bazzite.gg
org.universal-blue.pkg.kernel=<relver:kernel>
org.universal-blue.pkg.gamescope=<relver:gamescope>
# Generate tags after rechunker runs and checks the primary tag is not duplicated
# If it is, rechunk will suffix it by .1, .2, etc and put it in steps.rechunk.outputs.version
- name: Generate tags
id: generate-tags
shell: bash
run: |
# Common vars for generating tags
VERSION_TAG="${{ steps.rechunk.outputs.version }}"
UPSTREAM_TAG="${{ env.SOURCE_IMAGE_VERSION }}"
FEDORA_VERSION="${{ matrix.fedora_version }}"
SHA_SHORT="${GITHUB_SHA::7}"
BUILD_TAGS=( "${VERSION_TAG}" )
# Use latest var to check if we should tag as latest
unset LATEST
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
LATEST="1"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Track latest ver per PR
if [ -n "$LATEST" ]; then
BUILD_TAGS+=("pr-${{ github.event.pull_request.number }}")
fi
elif [[ ${{ github.ref_name }} == "unstable" ]]; then
# Per fedora version
BUILD_TAGS+=("${FEDORA_VERSION}-unstable")
BUILD_TAGS+=("unstable-${FEDORA_VERSION}") # flip ver to be last
if [ -n "$LATEST" ]; then
BUILD_TAGS+=("unstable")
fi
elif [[ ${{ github.ref_name }} == "testing" ]]; then
# Per fedora version
BUILD_TAGS+=("${FEDORA_VERSION}-testing")
BUILD_TAGS+=("testing-${FEDORA_VERSION}") # flip ver to be last
if [ -n "$LATEST" ]; then
BUILD_TAGS+=("testing")
fi
else
BUILD_TAGS+=("${FEDORA_VERSION}")
BUILD_TAGS+=("stable-${VERSION_TAG}")
# Per fedora version
BUILD_TAGS+=("${FEDORA_VERSION}-stable")
BUILD_TAGS+=("stable-${FEDORA_VERSION}") # flip ver to be last
if [ -n "$LATEST" ]; then
BUILD_TAGS+=("latest" "stable")
fi
fi
echo "Generated the following build tags: "
for TAG in "${BUILD_TAGS[@]}"; do
echo "${TAG}"
done
echo "alias_tags=${BUILD_TAGS[*]}" >> $GITHUB_OUTPUT
# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
# https://github.com/macbre/push-to-ghcr/issues/12
- name: Lowercase Registry
id: registry_case
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_REGISTRY }}
# Push the image to GHCR (Image Registry)
- name: Push To GHCR
uses: Wandalen/[email protected]
id: push
if: github.event_name != 'pull_request'
with:
attempt_limit: 3
attempt_delay: 15000
command: |
echo "${{ secrets.GITHUB_TOKEN }}" | sudo podman login ghcr.io -u ${{ github.actor }} --password-stdin
for tag in ${{ steps.generate-tags.outputs.alias_tags }}; do
sudo skopeo copy ${{ steps.rechunk.outputs.ref }} docker://${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}:$tag
done
- name: Get Image Digest
id: digest
run: |
# Get digest for signing
DIGEST=$(sudo skopeo inspect --format '{{.Digest}}' ${{ steps.rechunk.outputs.ref }})
echo "Digest is: $DIGEST"
echo "digest=${DIGEST}" >> $GITHUB_OUTPUT
- name: Sign container image
uses: EyeCantCU/cosign-action/[email protected]
if: github.event_name != 'pull_request'
with:
containers: ${{ env.IMAGE_NAME }}
registry-token: ${{ secrets.GITHUB_TOKEN }}
signing-secret: ${{ secrets.SIGNING_SECRET }}
tags: ${{ steps.digest.outputs.digest }}
generate_release:
name: Generate Release
needs: [push-ghcr]
if: github.event_name != 'pull_request'
secrets: inherit
uses: ./.github/workflows/generate_release.yml
build_iso:
name: Build ISO
needs: [push-ghcr]
if: github.ref_name == 'testing'
# Eventually would be nice for building images in PRs
#if: ${{ endsWith(github.event.pull_request.title, '[ISO]') }}
uses: ./.github/workflows/build_iso.yml
secrets: inherit