Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/reusable-build-bootc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ jobs:
fail-fast: false
matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix) }}
runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-26.04' || 'ubuntu-26.04-arm' }}
outputs:
image_version: ${{ steps.getversion.outputs.image_version }}
steps:
- name: Free disk space
uses: hastd/free-disk-space@68572aeaadb7f76bd408246328e95926323402b5 # v0.1.2
Expand All @@ -104,6 +106,10 @@ jobs:
sudo mv mkosi /usr/src/mkosi
sudo ln -sf "/usr/src/mkosi/bin/mkosi" /usr/bin/mkosi

- name: Set mkosi.version
# We need to do this because mkosi.version is not persistent between builds on CI
run: skopeo list-tags docker://${IMAGE_REGISTRY}/${IMAGE_NAME} | jq --arg date "$(date -u +%Y%m%d)" -r '.Tags[] | select(startswith($date+"."))' | sort -n | tail -1 > mkosi.version

- name: Render configuration (for debugging)
run: mkosi cat-config --debug

Expand All @@ -121,6 +127,12 @@ jobs:
fi
sudo mkosi -B -ff --debug --profile=bootc-ostree,${CI_MKOSI_PROFILES} ${PROFILE_ARGUMENTS} ${RELEASE_ARGUMENTS}

- name: Get Version
id: getversion
run: |
set -e
echo "image_version=$(cat mkosi.version)" >> "$GITHUB_OUTPUT"

- name: Load image
id: load
run: |
Expand Down Expand Up @@ -249,11 +261,11 @@ jobs:
type=raw,value=${{ steps.imagemetadata.outputs.distributionversion }}
type=raw,value=${{ env.DEFAULT_TAG }}-${{ github.sha }}
type=raw,value=${{ steps.imagemetadata.outputs.distributionversion }}-${{ github.sha }}
type=raw,value=${{ env.DEFAULT_TAG }}.{{date 'YYYYMMDD'}}
type=raw,value=${{ steps.imagemetadata.outputs.distributionversion }}.{{date 'YYYYMMDD'}}
type=raw,value=${{ env.DEFAULT_TAG }}.{{date 'YYYYMMDD'}}-${{ github.sha }}
type=raw,value=${{ steps.imagemetadata.outputs.distributionversion }}.{{date 'YYYYMMDD'}}-${{ github.sha }}
type=raw,value={{ date 'YYYYMMDD'}},enable=${{ env.DEFAULT_TAG == 'latest' }}
type=raw,value=${{ env.DEFAULT_TAG }}.${{ needs.build_push.outputs.image_version }}
type=raw,value=${{ steps.imagemetadata.outputs.distributionversion }}.${{ needs.build_push.outputs.image_version }}
type=raw,value=${{ env.DEFAULT_TAG }}.${{ needs.build_push.outputs.image_version }}-${{ github.sha }}
type=raw,value=${{ steps.imagemetadata.outputs.distributionversion }}.${{ needs.build_push.outputs.image_version }}-${{ github.sha }}
type=raw,value=${{ needs.build_push.outputs.image_version }},enable=${{ env.DEFAULT_TAG == 'latest' }}
type=ref,event=pr
type=sha,enable=${{ github.event_name == 'pull_request' }}
labels: |
Expand All @@ -272,7 +284,7 @@ jobs:
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.url=https://github.com/${{ github.repository }}/tree/${{ github.sha }}
org.opencontainers.image.vendor=${{ github.repository_owner }}
org.opencontainers.image.version=${{ env.DEFAULT_TAG }}.{{date 'YYYYMMDD'}}
org.opencontainers.image.version=${{ env.DEFAULT_TAG }}.${{ needs.build_push.outputs.image_version }}

- name: Login to GitHub Container Registry
if: inputs.publish
Expand Down
28 changes: 25 additions & 3 deletions mkosi.bump
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
#!/bin/bash
set -e
#!/usr/bin/env python
from datetime import datetime, timezone

DEFAULT_INDEX=0

cur_date = datetime.now(timezone.utc).strftime("%Y%m%d")
old_date = None
old_index = 0

# Try to find the old version. If the file is missing or fails to parse, don't do anything
try:
old_version = open("mkosi.version", "r").read().split(".")
if len(old_version) == 2:
old_date = old_version[0]
old_index = int(old_version[1])

except FileNotFoundError, ValueError:
pass

# If the date timestamp (YYYYMMDD) of the last built version is the same as the one we want to build, increment the counter index. If not, reset to 0
if old_date != cur_date:
print(f"{cur_date}.{DEFAULT_INDEX}")
else:
new_index = old_index + 1
print(f"{cur_date}.{new_index}")

date -u +%Y%m%d%H%M%S
1 change: 1 addition & 0 deletions mkosi.postinst.chroot
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ s|^DEFAULT_HOSTNAME=.*|DEFAULT_HOSTNAME="zirconium"|
/^REDHAT_SUPPORT_PRODUCT_VERSION=/d
EOF
echo "VARIANT_ID=container" >> /usr/lib/os-release
echo "IMAGE_VERSION=${IMAGE_VERSION}" >> /usr/lib/os-release
ln -s fedora-release /usr/lib/system-release