ci: generate changelog
All checks were successful
Build containers / Build and push image (push) Successful in 10m9s

This commit is contained in:
2026-03-01 16:47:28 +01:00
parent eb47b29286
commit c658c90c40
2 changed files with 140 additions and 25 deletions

View File

@@ -11,14 +11,13 @@ jobs:
build_push: build_push:
name: Build and push image name: Build and push image
runs-on: coole-runner runs-on: coole-runner
strategy:
fail-fast: false env:
matrix: IMAGE: asahi-cosmic
image: [asahi-cosmic] VERSION: 43
version: [43]
container: container:
image: "quay.io/fedora-ostree-desktops/buildroot:${{ matrix.version }}" image: "quay.io/fedora-ostree-desktops/buildroot:${{ env.VERSION }}"
options: "--security-opt=label=disable --privileged --user 0:0 --device=/dev/fuse --volume /:/run/host:rw" options: "--security-opt=label=disable --privileged --user 0:0 --device=/dev/fuse --volume /:/run/host:rw"
steps: steps:
@@ -26,7 +25,7 @@ jobs:
- name: Install rpm-ostree + tools - name: Install rpm-ostree + tools
run: | run: |
dnf upgrade -y --enablerepo=updates-testing --refresh rpm-ostree dnf upgrade -y --enablerepo=updates-testing --refresh rpm-ostree
dnf install -y nodejs skopeo jq buildah rsync dnf install -y nodejs skopeo jq buildah rsync git
mkdir -p ~/.docker mkdir -p ~/.docker
- name: Fix containers/storage.conf - name: Fix containers/storage.conf
@@ -35,6 +34,8 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to registry - name: Log in to registry
uses: redhat-actions/podman-login@v1 uses: redhat-actions/podman-login@v1
@@ -43,18 +44,15 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }} username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
auth_file_path: /tmp/auth.json auth_file_path: /tmp/auth.json
- name: Build rootfs with rpm-ostree - name: Build rootfs with rpm-ostree
run: | run: |
cd "$GITHUB_WORKSPACE" sudo -E ./builder.sh "${IMAGE}" "${VERSION}"
sudo -E ./builder.sh "${{ matrix.image }}" "${{ matrix.version }}"
- name: Build and push OCI image from rootfs - name: Build and push OCI image from rootfs
run: | run: |
set -xeuo pipefail set -xeuo pipefail
IMAGE="${{ matrix.image }}"
VERSION="${{ matrix.version }}"
REGISTRY="git.plabble.org/misthios" REGISTRY="git.plabble.org/misthios"
ROOTFS="images/${IMAGE}/rootfs" ROOTFS="images/${IMAGE}/rootfs"
@@ -71,10 +69,7 @@ jobs:
echo "${buildid}" > .buildid echo "${buildid}" > .buildid
fi fi
version="${VERSION}" full_tag="${VERSION}.${buildid}"
full_tag="${version}.${buildid}"
echo "Building OCI image from rootfs..."
export STORAGE_DRIVER=vfs export STORAGE_DRIVER=vfs
@@ -83,18 +78,13 @@ jobs:
rsync -aHAX "${ROOTFS}/" "${mnt}/" rsync -aHAX "${ROOTFS}/" "${mnt}/"
# REQUIRED FOR BOOTC
buildah config --label containers.bootc=1 "${ctr}" buildah config --label containers.bootc=1 "${ctr}"
buildah config --env container=oci "${ctr}" buildah config --env container=oci "${ctr}"
# CMD
buildah config --cmd "/sbin/init" "${ctr}" buildah config --cmd "/sbin/init" "${ctr}"
buildah commit "${ctr}" "localhost/${IMAGE}:${full_tag}" buildah commit "${ctr}" "localhost/${IMAGE}:${full_tag}"
buildah unmount "${ctr}" buildah unmount "${ctr}"
echo "Pushing image to registry..."
skopeo copy \ skopeo copy \
--authfile /tmp/auth.json \ --authfile /tmp/auth.json \
containers-storage:localhost/${IMAGE}:${full_tag} \ containers-storage:localhost/${IMAGE}:${full_tag} \
@@ -103,8 +93,17 @@ jobs:
skopeo copy \ skopeo copy \
--authfile /tmp/auth.json \ --authfile /tmp/auth.json \
containers-storage:localhost/${IMAGE}:${full_tag} \ containers-storage:localhost/${IMAGE}:${full_tag} \
docker://${REGISTRY}/${IMAGE}:${version} docker://${REGISTRY}/${IMAGE}:${VERSION}
echo "Pushed:" - name: Generate changelog
echo " - ${REGISTRY}/${IMAGE}:${full_tag}" run: |
echo " - ${REGISTRY}/${IMAGE}:${version}" ./changelog.sh "${IMAGE}" "${VERSION}"
- name: Commit and push changelog
if: github.ref == 'refs/heads/main'
run: |
git config user.name "Automation"
git config user.email "actions@invalid.tld"
git add changelogs/
git commit -m "Update changelog for ${IMAGE} ${VERSION} build $(cat .buildid)" || echo "No changes"
git push

116
changelog.sh Executable file
View File

@@ -0,0 +1,116 @@
#!/usr/bin/env bash
set -euo pipefail
IMAGE="$1"
VERSION="$2"
# Convert to absolute path
ROOTFS="$(realpath "images/${IMAGE}/rootfs")"
CHANGELOG_DIR="changelogs/${IMAGE}"
mkdir -p "${CHANGELOG_DIR}"
PKG_CUR="${CHANGELOG_DIR}/packages-current.txt"
PKG_PREV="${CHANGELOG_DIR}/packages-latest.txt"
BUILD_ID="$(cat .buildid)"
CHANGELOG_FILE="${CHANGELOG_DIR}/${VERSION}.${BUILD_ID}.json"
# Extract package list (name + evr)
rpm -qa --root "${ROOTFS}" --qf '%{NAME} %{EVR}\n' | sort > "${PKG_CUR}"
if [[ -f "${PKG_PREV}" ]]; then
CUR_NAMES="$(cut -d' ' -f1 "${PKG_CUR}" | sort)"
PREV_NAMES="$(cut -d' ' -f1 "${PKG_PREV}" | sort)"
ADDED_NAMES="$(comm -13 <(echo "${PREV_NAMES}") <(echo "${CUR_NAMES}"))"
REMOVED_NAMES="$(comm -23 <(echo "${PREV_NAMES}") <(echo "${CUR_NAMES}"))"
COMMON_NAMES="$(comm -12 <(echo "${PREV_NAMES}") <(echo "${CUR_NAMES}"))"
ADDED_LIST=()
while read -r name; do
[[ -z "$name" ]] && continue
ver="$(grep -E "^${name} " "${PKG_CUR}" | awk '{print $2}')"
ADDED_LIST+=("${name} ${ver}")
done <<< "${ADDED_NAMES}"
REMOVED_LIST=()
while read -r name; do
[[ -z "$name" ]] && continue
ver="$(grep -E "^${name} " "${PKG_PREV}" | awk '{print $2}')"
REMOVED_LIST+=("${name} ${ver}")
done <<< "${REMOVED_NAMES}"
UPDATED_LIST=()
while read -r name; do
[[ -z "$name" ]] && continue
old_ver="$(grep -E "^${name} " "${PKG_PREV}" | awk '{print $2}')"
new_ver="$(grep -E "^${name} " "${PKG_CUR}" | awk '{print $2}')"
if [[ "${old_ver}" != "${new_ver}" ]]; then
UPDATED_LIST+=("${name} ${old_ver} -> ${new_ver}")
fi
done <<< "${COMMON_NAMES}"
ADDED_COUNT="${#ADDED_LIST[@]}"
REMOVED_COUNT="${#REMOVED_LIST[@]}"
UPDATED_COUNT="${#UPDATED_LIST[@]}"
{
echo "{"
echo " \"image\": \"${IMAGE}\","
echo " \"version\": \"${VERSION}\","
echo " \"build_id\": \"${BUILD_ID}\","
echo " \"added_count\": ${ADDED_COUNT},"
echo " \"removed_count\": ${REMOVED_COUNT},"
echo " \"updated_count\": ${UPDATED_COUNT},"
echo " \"added\": ["
for i in "${!ADDED_LIST[@]}"; do
sep=$([[ $i -lt $((ADDED_COUNT-1)) ]] && echo "," || echo "")
printf ' "%s"%s\n' "${ADDED_LIST[$i]}" "${sep}"
done
echo " ],"
echo " \"removed\": ["
for i in "${!REMOVED_LIST[@]}"; do
sep=$([[ $i -lt $((REMOVED_COUNT-1)) ]] && echo "," || echo "")
printf ' "%s"%s\n' "${REMOVED_LIST[$i]}" "${sep}"
done
echo " ],"
echo " \"updated\": ["
for i in "${!UPDATED_LIST[@]}"; do
sep=$([[ $i -lt $((UPDATED_COUNT-1)) ]] && echo "," || echo "")
printf ' "%s"%s\n' "${UPDATED_LIST[$i]}" "${sep}"
done
echo " ]"
echo "}"
} > "${CHANGELOG_FILE}"
else
ADDED_LIST=()
while read -r name ver; do
ADDED_LIST+=("${name} ${ver}")
done < "${PKG_CUR}"
ADDED_COUNT="${#ADDED_LIST[@]}"
{
echo "{"
echo " \"image\": \"${IMAGE}\","
echo " \"version\": \"${VERSION}\","
echo " \"build_id\": \"${BUILD_ID}\","
echo " \"added_count\": ${ADDED_COUNT},"
echo " \"removed_count\": 0,"
echo " \"updated_count\": 0,"
echo " \"added\": ["
for i in "${!ADDED_LIST[@]}"; do
sep=$([[ $i -lt $((ADDED_COUNT-1)) ]] && echo "," || echo "")
printf ' "%s"%s\n' "${ADDED_LIST[$i]}" "${sep}"
done
echo " ],"
echo " \"removed\": [],"
echo " \"updated\": []"
echo "}"
} > "${CHANGELOG_FILE}"
fi
mv "${PKG_CUR}" "${PKG_PREV}"
echo "Changelog written to ${CHANGELOG_FILE}"