CI #169
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: CI | |
'on': | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
push: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DISTRIBUTION: ubuntu | |
RELEASE: jammy | |
permissions: | |
contents: write | |
steps: | |
- run: sudo apt-get -y update | |
- name: Install host dependencies with APT | |
uses: tecolicom/actions-use-any-tools@v1 | |
with: | |
apt: >2 | |
acl | |
coreutils | |
debootstrap | |
dosfstools | |
e2fsprogs | |
file | |
gdisk | |
liburing2 | |
lvm2 | |
mount | |
qemu-utils | |
rsync | |
systemd-container | |
util-linux | |
zstd | |
- name: Set image variables | |
run: |2 | |
printf -v IMAGE_ID '%s-%s-%s' "$DISTRIBUTION" "$RELEASE" "$RUNNER_ARCH" | |
printf -v IMAGE_VERSION '%(%Y-%m-%d)T' "-1" | |
printf -v IMAGE_OUTPUT_DIR '%s~%s' "$DISTRIBUTION" "$RELEASE" | |
printf -v IMAGE_NAME '%s_%s' "$IMAGE_ID" "$IMAGE_VERSION" | |
mapfile -t _VARIABLES < <(compgen -A variable) | |
for _var in "${_VARIABLES[@]}"; do | |
if [[ "$_var" =~ ^IMAGE_ ]]; then | |
printf '%s=%s\n' "$_var" "${!_var}" | |
fi | |
done >> "$GITHUB_ENV" | |
- name: Get code | |
uses: actions/checkout@v3 | |
- name: Setup python for mkosi | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
id: cp10 | |
- name: Install mkosi with PIP | |
run: pip install -r requirements.txt | |
- name: Cache/Restore mkosi.cache | |
uses: actions/cache@v3 | |
with: | |
path: mkosi.cache | |
key: ${{ env.IMAGE_ID }} | |
- name: Show build summary | |
run: sudo ${{ steps.cp10.outputs.python-path }} -m mkosi --mirror http://azure.archive.ubuntu.com/ubuntu --image-version "$IMAGE_VERSION" --image-id "$IMAGE_ID" summary | |
- name: Build image | |
run: sudo ${{ steps.cp10.outputs.python-path }} -m mkosi --mirror http://azure.archive.ubuntu.com/ubuntu --image-version "$IMAGE_VERSION" --image-id "$IMAGE_ID" --force build | |
- name: Augment manifest | |
run: ${{ steps.cp10.outputs.python-path }} augment_manifest.py "mkosi.output/${IMAGE_OUTPUT_DIR}/${IMAGE_NAME}.manifest" | |
- run: mv "${IMAGE_NAME}.manifest" "${IMAGE_NAME}.manifest.new" | |
working-directory: mkosi.output/${{ env.IMAGE_OUTPUT_DIR }} | |
- name: Get latest release manifest | |
uses: dsaltares/[email protected] | |
with: | |
file: "${{ env.IMAGE_ID }}_.*\\.manifest" | |
regex: true | |
target: "./mkosi.output/${{ env.IMAGE_OUTPUT_DIR }}/" | |
id: last_release | |
- run: mv "${IMAGE_ID}_${{ steps.last_release.outputs.version }}.manifest" "${IMAGE_ID}_${{ steps.last_release.outputs.version}}.manifest.old" | |
working-directory: mkosi.output/${{ env.IMAGE_OUTPUT_DIR }} | |
- run: mv "${IMAGE_NAME}.manifest.new" "${IMAGE_NAME}.manifest" | |
working-directory: mkosi.output/${{ env.IMAGE_OUTPUT_DIR }} | |
- name: Compare releases | |
id: do_releases_match | |
run: ${{ steps.cp10.outputs.python-path }} compare_manifests.py "mkosi.output/$IMAGE_OUTPUT_DIR/${IMAGE_ID}_${{ steps.last_release.outputs.version }}.manifest.old" "mkosi.output/$IMAGE_OUTPUT_DIR/$IMAGE_NAME.manifest" | |
- name: Compute checksums | |
if: steps.do_releases_match.outputs.value == 'false' | |
run: sha512sum "${IMAGE_NAME}.manifest" "${IMAGE_NAME}.qcow2" > "${IMAGE_NAME}.sha512" | |
working-directory: mkosi.output/${{ env.IMAGE_OUTPUT_DIR }} | |
- name: Release ${{ env.IMAGE_VERSION }} | |
if: steps.do_releases_match.outputs.value == 'false' | |
uses: softprops/[email protected] | |
with: | |
files: |2 | |
mkosi.output/${{ env.IMAGE_OUTPUT_DIR }}/${{ env.IMAGE_NAME }}.sha512 | |
mkosi.output/${{ env.IMAGE_OUTPUT_DIR }}/${{ env.IMAGE_NAME }}.manifest | |
mkosi.output/${{ env.IMAGE_OUTPUT_DIR }}/${{ env.IMAGE_NAME }}.qcow2 | |
mkosi.output/${{ env.IMAGE_OUTPUT_DIR }}/${{ env.IMAGE_NAME }}.raw.zst | |
tag_name: ${{ env.IMAGE_VERSION }} | |
- name: Make mkosi.cache cachable for GitHub | |
run: sudo setfacl -R -m "u:$UID:rwx" mkosi.cache | |
if: always() |