Skip to content

Commit 7652b5e

Browse files
committed
feat: standardize versioning across OSTree and os-release
1 parent 54fad61 commit 7652b5e

File tree

3 files changed

+120
-60
lines changed

3 files changed

+120
-60
lines changed

.github/workflows/build.yml

+106-59
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
fedora_version: [40]
6262
include:
6363
- fedora_version: 40
64+
bazzite_version: "v3.6"
6465
is_latest_version: true
6566
is_stable_version: true
6667
kernel_flavor: fsync # must match a kernel_flavor from akmods repo
@@ -133,64 +134,6 @@ jobs:
133134
- name: Maximize build space
134135
uses: ublue-os/remove-unwanted-software@v7
135136

136-
- name: Generate tags
137-
id: generate-tags
138-
shell: bash
139-
run: |
140-
# Generate a timestamp for creating an image version history
141-
TIMESTAMP="$(date +%Y%m%d)"
142-
FEDORA_VERSION="${{ matrix.fedora_version }}"
143-
COMMIT_TAGS=()
144-
BUILD_TAGS=()
145-
# Have tags for tracking builds during pull request
146-
SHA_SHORT="${GITHUB_SHA::7}"
147-
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}-${FEDORA_VERSION}")
148-
COMMIT_TAGS+=("${SHA_SHORT}-${FEDORA_VERSION}")
149-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
150-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
151-
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}")
152-
COMMIT_TAGS+=("${SHA_SHORT}")
153-
fi
154-
155-
if [[ ${{ github.ref_name }} == "unstable" ]]; then
156-
BUILD_TAGS=("${FEDORA_VERSION}-unstable" "${FEDORA_VERSION}-unstable-${TIMESTAMP}")
157-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
158-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
159-
BUILD_TAGS+=("unstable")
160-
echo "DEFAULT_TAG=unstable" >> $GITHUB_ENV
161-
fi
162-
elif [[ ${{ github.ref_name }} == "testing" ]]; then
163-
BUILD_TAGS=("${FEDORA_VERSION}-testing" "${FEDORA_VERSION}-testing-${TIMESTAMP}")
164-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
165-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
166-
BUILD_TAGS+=("testing")
167-
echo "DEFAULT_TAG=testing" >> $GITHUB_ENV
168-
fi
169-
else
170-
BUILD_TAGS=("${FEDORA_VERSION}" "${FEDORA_VERSION}-${TIMESTAMP}")
171-
BUILD_TAGS+=("${FEDORA_VERSION}-stable" "${FEDORA_VERSION}-stable-${TIMESTAMP}")
172-
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
173-
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
174-
BUILD_TAGS+=("latest" "stable")
175-
echo "DEFAULT_TAG=latest" >> $GITHUB_ENV
176-
fi
177-
fi
178-
179-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
180-
echo "Generated the following commit tags: "
181-
for TAG in "${COMMIT_TAGS[@]}"; do
182-
echo "${TAG}"
183-
done
184-
alias_tags=("${COMMIT_TAGS[@]}")
185-
else
186-
alias_tags=("${BUILD_TAGS[@]}")
187-
fi
188-
echo "Generated the following build tags: "
189-
for TAG in "${BUILD_TAGS[@]}"; do
190-
echo "${TAG}"
191-
done
192-
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
193-
194137
- name: Pull main, akmods, rechunk images
195138
uses: Wandalen/wretry.action@v3.5.0
196139
with:
@@ -229,6 +172,38 @@ jobs:
229172
exit 1
230173
fi
231174
echo "KERNEL_VERSION=$linux" >> $GITHUB_ENV
175+
176+
# Generate a primary version key that appears
177+
# in KDE, rpm-ostree status, and github.
178+
- name: Generate Version
179+
id: generate-version
180+
shell: bash
181+
run: |
182+
# Generate the primary version key that will be stored on os-release,
183+
# shown on the bootloader, and used for the image tag.
184+
UPSTREAM_TAG="${{ env.SOURCE_IMAGE_VERSION }}"
185+
FEDORA_VERSION="${{ matrix.fedora_version }}"
186+
BAZZITE_VERSION="${{ matrix.bazzite_version }}"
187+
SHA_SHORT="${GITHUB_SHA::7}"
188+
189+
if [ -n "${{ github.event.pull_request.number }}" ]; then
190+
VERSION="pr-${FEDORA_VERSION}-${{ github.event.pull_request.number }}"
191+
PRETTY_VERSION="PR (${{ github.event.pull_request.number }}, ${UPSTREAM_TAG})"
192+
elif [[ ${{ github.ref_name }} == "unstable" ]]; then
193+
VERSION="unstable-${SHA_SHORT}"
194+
PRETTY_VERSION="Unstable (#${SHA_SHORT}, F${UPSTREAM_TAG})"
195+
elif [[ ${{ github.ref_name }} == "testing" ]]; then
196+
VERSION="testing-${BAZZITE_VERSION}-${UPSTREAM_TAG}"
197+
PRETTY_VERSION="Testing (${BAZZITE_VERSION}, F${UPSTREAM_TAG})"
198+
else
199+
VERSION="${BAZZITE_VERSION}-${UPSTREAM_TAG}"
200+
PRETTY_VERSION="Stable (${BAZZITE_VERSION}, F${UPSTREAM_TAG})"
201+
fi
202+
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
203+
echo "pretty=${PRETTY_VERSION}" >> $GITHUB_OUTPUT
204+
205+
echo "Generated the following:"
206+
cat $GITHUB_OUTPUT
232207
233208
# Build image using buildah and save it to raw-img
234209
- name: Build Image
@@ -245,6 +220,8 @@ jobs:
245220
--build-arg KERNEL_FLAVOR=${{ matrix.kernel_flavor }} \
246221
--build-arg IMAGE_BRANCH=${{ github.ref_name }} \
247222
--build-arg SHA_HEAD_SHORT=${{ env.SHA_HEAD_SHORT }} \
223+
--build-arg VERSION_TAG=${{ steps.generate-version.outputs.tag }} \
224+
--build-arg VERSION_PRETTY="${{ steps.generate-version.outputs.pretty }}" \
248225
--tag raw-img .
249226
250227
- name: Remove auxiliary images
@@ -265,7 +242,7 @@ jobs:
265242
# to avoid layer shifts.
266243
# prev-ref: ${{ github.event.inputs.fresh-rechunk == 'true' && '' || 'ghcr.io/ublue-os/bazzite:unstable' }}
267244
rechunk: 'ghcr.io/hhd-dev/rechunk:v0.1.8'
268-
version: '${{ env.SOURCE_IMAGE_VERSION }}'
245+
version: '${{ steps.generate-version.outputs.tag }}'
269246
labels: |
270247
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/ublue-os/bazzite/main/repo_content/logo.png
271248
io.artifacthub.package.readme-url=https://bazzite.gg/
@@ -276,6 +253,76 @@ jobs:
276253
org.opencontainers.image.source=https://github.com/ublue-os/bazzite
277254
org.opencontainers.image.title=bazzite
278255
org.opencontainers.image.url=https://github.com/ublue-os/bazzite
256+
257+
# Generate tags after rechunker runs and checks the primary tag is not duplicated
258+
# If it is, rechunk will suffix it by .1, .2, etc and put it in steps.rechunk.outputs.version
259+
- name: Generate tags
260+
id: generate-tags
261+
shell: bash
262+
run: |
263+
# Common vars for generating tags
264+
VERSION_TAG="${{ steps.rechunk.outputs.version }}"
265+
UPSTREAM_TAG="${{ env.SOURCE_IMAGE_VERSION }}"
266+
FEDORA_VERSION="${{ matrix.fedora_version }}"
267+
BAZZITE_VERSION="${{ matrix.bazzite_version }}"
268+
SHA_SHORT="${GITHUB_SHA::7}"
269+
BUILD_TAGS=( "${VERSION_TAG}" )
270+
271+
# Use latest var to check if we should tag as latest
272+
unset LATEST
273+
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
274+
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
275+
LATEST="1"
276+
fi
277+
278+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
279+
# Track latest ver per PR
280+
if [ -n "$LATEST" ]; then
281+
BUILD_TAGS+=("pr-${{ github.event.pull_request.number }}")
282+
fi
283+
elif [[ ${{ github.ref_name }} == "unstable" ]]; then
284+
# Per fedora version
285+
BUILD_TAGS+=("${FEDORA_VERSION}-unstable")
286+
BUILD_TAGS+=("unstable-${FEDORA_VERSION}") # flip ver to be last
287+
288+
# Per upstream ver
289+
BUILD_TAGS+=("unstable-${UPSTREAM_TAG}")
290+
291+
if [ -n "$LATEST" ]; then
292+
BUILD_TAGS+=("unstable")
293+
fi
294+
elif [[ ${{ github.ref_name }} == "testing" ]]; then
295+
# Per fedora version
296+
BUILD_TAGS+=("${FEDORA_VERSION}-testing")
297+
BUILD_TAGS+=("testing-${FEDORA_VERSION}") # flip ver to be last
298+
299+
# Per upstream ver
300+
BUILD_TAGS+=("testing-${UPSTREAM_TAG}")
301+
302+
if [ -n "$LATEST" ]; then
303+
BUILD_TAGS+=("testing-${BAZZITE_VERSION}")
304+
BUILD_TAGS+=("testing")
305+
fi
306+
else
307+
BUILD_TAGS+=("${FEDORA_VERSION}")
308+
BUILD_TAGS+=("${UPSTREAM_TAG}")
309+
BUILD_TAGS+=("${BAZZITE_VERSION}")
310+
BUILD_TAGS+=("stable-${UPSTREAM_TAG}")
311+
312+
# Per fedora version
313+
BUILD_TAGS+=("${FEDORA_VERSION}-stable")
314+
BUILD_TAGS+=("stable-${FEDORA_VERSION}") # flip ver to be last
315+
316+
if [ -n "$LATEST" ]; then
317+
BUILD_TAGS+=("latest" "stable")
318+
fi
319+
fi
320+
321+
echo "Generated the following build tags: "
322+
for TAG in "${BUILD_TAGS[@]}"; do
323+
echo "${TAG}"
324+
done
325+
echo "alias_tags=${BUILD_TAGS[*]}" >> $GITHUB_OUTPUT
279326
280327
# Pull oci-dir image, remove oci dir to make space, and then tag appropriately
281328
- name: Load in podman and tag

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)