Skip to content

Commit 677891a

Browse files
authored
feat: standardize versioning across OSTree and os-release (#1442)
1 parent fd05f5a commit 677891a

File tree

3 files changed

+132
-63
lines changed

3 files changed

+132
-63
lines changed

.github/workflows/build.yml

+118-62
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
fedora_version: [40]
6464
include:
6565
- fedora_version: 40
66+
bazzite_version: "v3.6"
6667
is_latest_version: true
6768
is_stable_version: true
6869
kernel_flavor: fsync # must match a kernel_flavor from akmods repo
@@ -135,64 +136,6 @@ jobs:
135136
- name: Maximize build space
136137
uses: ublue-os/remove-unwanted-software@v7
137138

138-
- name: Generate tags
139-
id: generate-tags
140-
shell: bash
141-
run: |
142-
# Generate a timestamp for creating an image version history
143-
TIMESTAMP="$(date +%Y%m%d)"
144-
FEDORA_VERSION="${{ matrix.fedora_version }}"
145-
COMMIT_TAGS=()
146-
BUILD_TAGS=()
147-
# Have tags for tracking builds during pull request
148-
SHA_SHORT="${GITHUB_SHA::7}"
149-
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}-${FEDORA_VERSION}")
150-
COMMIT_TAGS+=("${SHA_SHORT}-${FEDORA_VERSION}")
151-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
152-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
153-
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}")
154-
COMMIT_TAGS+=("${SHA_SHORT}")
155-
fi
156-
157-
if [[ ${{ github.ref_name }} == "unstable" ]]; then
158-
BUILD_TAGS=("${FEDORA_VERSION}-unstable" "${FEDORA_VERSION}-unstable-${TIMESTAMP}")
159-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
160-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
161-
BUILD_TAGS+=("unstable")
162-
echo "DEFAULT_TAG=unstable" >> $GITHUB_ENV
163-
fi
164-
elif [[ ${{ github.ref_name }} == "testing" ]]; then
165-
BUILD_TAGS=("${FEDORA_VERSION}-testing" "${FEDORA_VERSION}-testing-${TIMESTAMP}")
166-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
167-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
168-
BUILD_TAGS+=("testing")
169-
echo "DEFAULT_TAG=testing" >> $GITHUB_ENV
170-
fi
171-
else
172-
BUILD_TAGS=("${FEDORA_VERSION}" "${FEDORA_VERSION}-${TIMESTAMP}")
173-
BUILD_TAGS+=("${FEDORA_VERSION}-stable" "${FEDORA_VERSION}-stable-${TIMESTAMP}")
174-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
175-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
176-
BUILD_TAGS+=("latest" "stable")
177-
echo "DEFAULT_TAG=latest" >> $GITHUB_ENV
178-
fi
179-
fi
180-
181-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
182-
echo "Generated the following commit tags: "
183-
for TAG in "${COMMIT_TAGS[@]}"; do
184-
echo "${TAG}"
185-
done
186-
alias_tags=("${COMMIT_TAGS[@]}")
187-
else
188-
alias_tags=("${BUILD_TAGS[@]}")
189-
fi
190-
echo "Generated the following build tags: "
191-
for TAG in "${BUILD_TAGS[@]}"; do
192-
echo "${TAG}"
193-
done
194-
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
195-
196139
- name: Pull main, akmods, rechunk images
197140
uses: Wandalen/[email protected]
198141
with:
@@ -206,7 +149,7 @@ jobs:
206149
sudo podman pull ${{ env.IMAGE_REGISTRY }}/akmods-nvidia:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}
207150
208151
# Add rechunk as well to remove this source of failure
209-
sudo podman pull ghcr.io/hhd-dev/rechunk:v0.2.1
152+
sudo podman pull ghcr.io/hhd-dev/rechunk:v0.5.0
210153
211154
- name: Get source versions
212155
id: labels
@@ -231,6 +174,38 @@ jobs:
231174
exit 1
232175
fi
233176
echo "KERNEL_VERSION=$linux" >> $GITHUB_ENV
177+
178+
# Generate a primary version key that appears
179+
# in KDE, rpm-ostree status, and github.
180+
- name: Generate Version
181+
id: generate-version
182+
shell: bash
183+
run: |
184+
# Generate the primary version key that will be stored on os-release,
185+
# shown on the bootloader, and used for the image tag.
186+
UPSTREAM_TAG="${{ env.SOURCE_IMAGE_VERSION }}"
187+
FEDORA_VERSION="${{ matrix.fedora_version }}"
188+
BAZZITE_VERSION="${{ matrix.bazzite_version }}"
189+
SHA_SHORT="${GITHUB_SHA::7}"
190+
191+
if [ -n "${{ github.event.pull_request.number }}" ]; then
192+
VERSION="pr-${FEDORA_VERSION}-${{ github.event.pull_request.number }}"
193+
PRETTY_VERSION="PR (${{ github.event.pull_request.number }}, ${UPSTREAM_TAG})"
194+
elif [[ ${{ github.ref_name }} == "unstable" ]]; then
195+
VERSION="unstable-${SHA_SHORT}"
196+
PRETTY_VERSION="Unstable (#${SHA_SHORT}, F${UPSTREAM_TAG})"
197+
elif [[ ${{ github.ref_name }} == "testing" ]]; then
198+
VERSION="testing-${BAZZITE_VERSION}-${UPSTREAM_TAG}"
199+
PRETTY_VERSION="Testing (${BAZZITE_VERSION}, F${UPSTREAM_TAG})"
200+
else
201+
VERSION="${BAZZITE_VERSION}-${UPSTREAM_TAG}"
202+
PRETTY_VERSION="Stable (${BAZZITE_VERSION}, F${UPSTREAM_TAG})"
203+
fi
204+
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
205+
echo "pretty=${PRETTY_VERSION}" >> $GITHUB_OUTPUT
206+
207+
echo "Generated the following:"
208+
cat $GITHUB_OUTPUT
234209
235210
# Build image using buildah and save it to raw-img
236211
- name: Build Image
@@ -247,6 +222,8 @@ jobs:
247222
--build-arg KERNEL_FLAVOR=${{ matrix.kernel_flavor }} \
248223
--build-arg IMAGE_BRANCH=${{ github.ref_name }} \
249224
--build-arg SHA_HEAD_SHORT=${{ env.SHA_HEAD_SHORT }} \
225+
--build-arg VERSION_TAG=${{ steps.generate-version.outputs.tag }} \
226+
--build-arg VERSION_PRETTY="${{ steps.generate-version.outputs.pretty }}" \
250227
--tag raw-img .
251228
252229
- name: Remove auxiliary images
@@ -259,12 +236,12 @@ jobs:
259236
# Reprocess raw-img using rechunker which will delete it
260237
- name: Run Rechunker
261238
id: rechunk
262-
uses: hhd-dev/rechunk@v0.2.1
239+
uses: hhd-dev/rechunk@v0.5.0
263240
with:
264-
rechunk: 'ghcr.io/hhd-dev/rechunk:v0.2.1'
241+
rechunk: 'ghcr.io/hhd-dev/rechunk:v0.5.0'
265242
ref: 'raw-img'
266243
prev-ref: ${{ github.event.inputs.fresh-rechunk == 'true' && '' || 'ghcr.io/ublue-os/bazzite:unstable' }}
267-
version: '${{ env.SOURCE_IMAGE_VERSION }}'
244+
version: '${{ steps.generate-version.outputs.tag }}'
268245
labels: |
269246
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/ublue-os/bazzite/main/repo_content/logo.png
270247
io.artifacthub.package.readme-url=https://bazzite.gg/
@@ -276,6 +253,85 @@ jobs:
276253
org.opencontainers.image.title=bazzite
277254
org.opencontainers.image.url=https://github.com/ublue-os/bazzite
278255
256+
org.universal-blue.pkg.kernel=<relver:kernel>
257+
org.universal-blue.pkg.gamescope=<relver:gamescope>
258+
${{ matrix.base_image_name == "kinoite" && "org.universal-blue.pkg.kwayland=<version:kwayland>" || "" }}
259+
${{ matrix.base_name == "bazzite-deck" && "org.universal-blue.pkg.hhd=<version:hhd>" || "" }}
260+
${{ matrix.base_name == "bazzite-deck" && "org.universal-blue.pkg.hhd=<version:adjustor>" || "" }}
261+
${{ matrix.base_name == "bazzite-deck" && "org.universal-blue.pkg.hhd=<version:hhd-ui>" || "" }}
262+
263+
org.universal-blue.info=<imginfo>
264+
265+
# Generate tags after rechunker runs and checks the primary tag is not duplicated
266+
# If it is, rechunk will suffix it by .1, .2, etc and put it in steps.rechunk.outputs.version
267+
- name: Generate tags
268+
id: generate-tags
269+
shell: bash
270+
run: |
271+
# Common vars for generating tags
272+
VERSION_TAG="${{ steps.rechunk.outputs.version }}"
273+
UPSTREAM_TAG="${{ env.SOURCE_IMAGE_VERSION }}"
274+
FEDORA_VERSION="${{ matrix.fedora_version }}"
275+
BAZZITE_VERSION="${{ matrix.bazzite_version }}"
276+
SHA_SHORT="${GITHUB_SHA::7}"
277+
BUILD_TAGS=( "${VERSION_TAG}" )
278+
279+
# Use latest var to check if we should tag as latest
280+
unset LATEST
281+
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
282+
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
283+
LATEST="1"
284+
fi
285+
286+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
287+
# Track latest ver per PR
288+
if [ -n "$LATEST" ]; then
289+
BUILD_TAGS+=("pr-${{ github.event.pull_request.number }}")
290+
fi
291+
elif [[ ${{ github.ref_name }} == "unstable" ]]; then
292+
# Per fedora version
293+
BUILD_TAGS+=("${FEDORA_VERSION}-unstable")
294+
BUILD_TAGS+=("unstable-${FEDORA_VERSION}") # flip ver to be last
295+
296+
# Per upstream ver
297+
BUILD_TAGS+=("unstable-${UPSTREAM_TAG}")
298+
299+
if [ -n "$LATEST" ]; then
300+
BUILD_TAGS+=("unstable")
301+
fi
302+
elif [[ ${{ github.ref_name }} == "testing" ]]; then
303+
# Per fedora version
304+
BUILD_TAGS+=("${FEDORA_VERSION}-testing")
305+
BUILD_TAGS+=("testing-${FEDORA_VERSION}") # flip ver to be last
306+
307+
# Per upstream ver
308+
BUILD_TAGS+=("testing-${UPSTREAM_TAG}")
309+
310+
if [ -n "$LATEST" ]; then
311+
BUILD_TAGS+=("testing-${BAZZITE_VERSION}")
312+
BUILD_TAGS+=("testing")
313+
fi
314+
else
315+
BUILD_TAGS+=("${FEDORA_VERSION}")
316+
BUILD_TAGS+=("${UPSTREAM_TAG}")
317+
BUILD_TAGS+=("${BAZZITE_VERSION}")
318+
BUILD_TAGS+=("stable-${UPSTREAM_TAG}")
319+
320+
# Per fedora version
321+
BUILD_TAGS+=("${FEDORA_VERSION}-stable")
322+
BUILD_TAGS+=("stable-${FEDORA_VERSION}") # flip ver to be last
323+
324+
if [ -n "$LATEST" ]; then
325+
BUILD_TAGS+=("latest" "stable")
326+
fi
327+
fi
328+
329+
echo "Generated the following build tags: "
330+
for TAG in "${BUILD_TAGS[@]}"; do
331+
echo "${TAG}"
332+
done
333+
echo "alias_tags=${BUILD_TAGS[*]}" >> $GITHUB_OUTPUT
334+
279335
# Pull oci-dir image, remove oci dir to make space, and then tag appropriately
280336
- name: Load in podman and tag
281337
run: |

Containerfile

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ARG BASE_IMAGE="ghcr.io/ublue-os/${SOURCE_IMAGE}"
88
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"
99
ARG JUPITER_KERNEL_VERSION="${JUPITER_KERNEL_VERSION:-jupiter-20240605.1}"
1010
ARG SHA_HEAD_SHORT="${SHA_HEAD_SHORT}"
11+
ARG VERSION_TAG="${VERSION_TAG}"
12+
ARG VERSION_PRETTY="${VERSION_PRETTY}"
1113

1214
FROM ghcr.io/ublue-os/akmods:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} AS akmods
1315
FROM ghcr.io/ublue-os/akmods-extra:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} AS akmods-extra
@@ -24,6 +26,8 @@ ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME:-kinoite}"
2426
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"
2527
ARG JUPITER_KERNEL_VERSION="${JUPITER_KERNEL_VERSION:-jupiter-20240605.1}"
2628
ARG SHA_HEAD_SHORT="${SHA_HEAD_SHORT}"
29+
ARG VERSION_TAG="${VERSION_TAG}"
30+
ARG VERSION_PRETTY="${VERSION_PRETTY}"
2731

2832
COPY system_files/desktop/shared system_files/desktop/${BASE_IMAGE_NAME} /
2933

@@ -692,6 +696,8 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-fsync}"
692696
ARG IMAGE_BRANCH="${IMAGE_BRANCH:-main}"
693697
ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME:-kinoite}"
694698
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"
699+
ARG VERSION_TAG="${VERSION_TAG}"
700+
ARG VERSION_PRETTY="${VERSION_PRETTY}"
695701

696702
COPY system_files/deck/shared system_files/deck/${BASE_IMAGE_NAME} /
697703

@@ -841,6 +847,8 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-fsync}"
841847
ARG IMAGE_BRANCH="${IMAGE_BRANCH:-main}"
842848
ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME:-kinoite}"
843849
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"
850+
ARG VERSION_TAG="${VERSION_TAG}"
851+
ARG VERSION_PRETTY="${VERSION_PRETTY}"
844852

845853
# Fetch NVIDIA driver
846854
COPY system_files/nvidia/shared system_files/nvidia/${BASE_IMAGE_NAME} /

system_files/desktop/shared/usr/libexec/containerbuild/image-info

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ cat > $IMAGE_INFO <<EOF
3838
"image-tag": "$IMAGE_TAG",
3939
"image-branch": "$IMAGE_BRANCH_NORMALIZED",
4040
"base-image-name": "$BASE_IMAGE_NAME",
41-
"fedora-version": "$FEDORA_MAJOR_VERSION"
41+
"fedora-version": "$FEDORA_MAJOR_VERSION",
42+
"version": "$VERSION_TAG",
43+
"version-pretty": "$VERSION_PRETTY"
4244
}
4345
EOF
4446

@@ -62,5 +64,8 @@ if [[ -n "${SHA_HEAD_SHORT:-}" ]]; then
6264
echo "BUILD_ID=\"$SHA_HEAD_SHORT\"" >> /usr/lib/os-release
6365
fi
6466

67+
# FIXME: Pretty name needs to have deck/KDE/GNOME/etc
68+
echo "BOOTLOADER_NAME=\"$IMAGE_PRETTY_NAME $VERSION_PRETTY\"" >> /usr/lib/os-release
69+
6570
# Fix issues caused by ID no longer being fedora
6671
sed -i "s/^EFIDIR=.*/EFIDIR=\"fedora\"/" /usr/sbin/grub2-switch-to-blscfg

0 commit comments

Comments
 (0)