-
Notifications
You must be signed in to change notification settings - Fork 1
186 lines (170 loc) · 6.35 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
name: Build m2os
on:
schedule:
- cron: "41 6 * * 2" # 6:41 UTC every Tuesday
push:
branches:
- main
merge_group:
workflow_dispatch:
env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_NAME: m2os
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
push-ghcr:
name: Build Images
runs-on: ubuntu-24.04
continue-on-error: false
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
image:
- bluefin
- bluefin-nvidia
- aurora
- aurora-nvidia
- bazzite-deck-gnome
- bazzite-gnome-nvidia
steps:
- name: Build Variables
id: labels
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 3
attempt_delay: 15000
command: |
set -eo pipefail
KERNEL_RELEASE=$(skopeo inspect docker://ghcr.io/ublue-os/${{ matrix.image }}:stable | jq -r '.Labels["ostree.linux"] | split(".x86_64")[0]')
fedora_version=$(echo $KERNEL_RELEASE | grep -oP 'fc\K[0-9]+')
ver=$(skopeo inspect docker://ghcr.io/ublue-os/${{ matrix.image }}:stable | jq -r '.Labels["org.opencontainers.image.version"]')
echo "fedora_version=$fedora_version" >> $GITHUB_OUTPUT
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
echo "inspected image version must not be empty or null"
exit 1
fi
if [[ ${{ matrix.image }} =~ "bazzite" ]]; then
kernel_flavor=fsync
upstream_repo=bazzite
else
kernel_flavor=coreos
upstream_repo=bluefin
fi
echo "version=$ver" >> $GITHUB_ENV
echo "kernel_release=${KERNEL_RELEASE}" >> $GITHUB_ENV
echo "fedora_version=${fedora_version}" >> $GITHUB_ENV
echo "kernel_flavor=${kernel_flavor}" >> $GITHUB_ENV
echo "upstream_repo=${upstream_repo}" >> $GITHUB_ENV
- name: Verify Base Image
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: ${{ matrix.image }}:stable
pubkey: https://raw.githubusercontent.com/ublue-os/${{ env.upstream_repo }}/main/cosign.pub
registry: ghcr.io/ublue-os
- name: Checkout Push to Registry Action
uses: actions/checkout@v4
- name: Maximize Build Space
if: matrix.image == 'bazzite-gnome-nvidia'
uses: ublue-os/remove-unwanted-software@v7
- name: Generate Tags
id: generate_tags
shell: bash
run: |
TIMESTAMP="$(date +%Y%m%d)"
if [[ "${{ matrix.image }}" =~ "bazzite-deck" ]]; then
tag="bazzite-deck"
elif [[ "${{ matrix.image }}" =~ "bazzite" ]]; then
tag="bazzite"
else
tag=${{ matrix.image }}
fi
BUILD_TAGS+=("${tag}" "${tag}-${TIMESTAMP}")
for TAG in "${BUILD_TAGS[@]}"; do
echo "${TAG}"
done
echo "default_tag=${tag}" >> "$GITHUB_OUTPUT"
echo "build_tags=${BUILD_TAGS[*]}" >> "$GITHUB_OUTPUT"
- name: Pull Images
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 3
attempt_delay: 15000
command: |
podman pull ghcr.io/ublue-os/${{ matrix.image }}:stable
podman pull ghcr.io/ublue-os/akmods:${{ env.kernel_flavor }}-${{ env.fedora_version }}
- name: Image Metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=m2os is my OCI image built from ublue projects. It mainly extends bazzite/bluefin for my uses.
org.opencontainers.image.version=${{ env.version }}
ostree.linux=${{ env.kernel_release }}.x86_64
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: |
./Containerfile
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.generate_tags.outputs.build_tags }}
build-args: |
IMAGE=${{ matrix.image }}
FEDORA_VERSION=${{ env.fedora_version }}
KERNEL_FLAVOR=${{ env.kernel_flavor }}
labels: ${{ steps.meta.outputs.labels }}
oci: false
- name: Lowercase Registry
id: registry_case
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_REGISTRY }}
- name: Push to GHCR
uses: Wandalen/wretry.action@v3.5.0
id: push
if: github.event_name != 'pull_request'
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
with:
action: redhat-actions/push-to-registry@v2
attempt_limit: 3
attempt_delay: 15000
with: |
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
extra-args: |
--disable-content-trust
# --compression-format=zstd:chunked
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: sigstore/cosign-installer@v3.5.0
if: github.event_name != 'pull_request'
- name: Sign Container Image
if: github.event_name != 'pull_request'
run: |
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}@${TAGS}
env:
TAGS: ${{ steps.push.outputs.outputs && fromJSON(steps.push.outputs.outputs).digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
- name: Echo Outputs
if: github.event_name != 'pull_request'
run: |
echo "${{ toJSON(steps.push.outputs) }}"