Test the image in CI #129
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: 'Build mkosi image' | |
on: | |
workflow_dispatch: | |
push: | |
branches: ['main'] | |
tags: ['*'] | |
permissions: | |
contents: write | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install mkosi dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends \ | |
python3 python3-pip python-is-python3 python3-pyelftools python3-pefile pipx \ | |
qemu-user-static binfmt-support bubblewrap dosfstools mtools uidmap debian-archive-keyring \ | |
binutils-aarch64-linux-gnu jq rename | |
- name: Install mkosi | |
run: | | |
pipx ensurepath | |
pipx install git+https://github.com/systemd/[email protected] | |
- name: Setup mkosi cache | |
id: mkosi-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: mkosi.cache.tar.zst | |
key: mkosi-${{ hashFiles('mkosi.conf') }} | |
- name: Extract cache | |
if: steps.mkosi-cache.outputs.cache-hit == 'true' | |
run: sudo tar -xf mkosi.cache.tar.zst --use-compress-program zstdmt | |
- name: Setup mkosi | |
run: | | |
touch mkosi.key mkosi.crt | |
chmod 0600 mkosi.key mkosi.crt | |
cat << EOF > mkosi.key | |
${{ secrets.MKOSI_KEY }} | |
EOF | |
cat << EOF > mkosi.crt | |
${{ secrets.MKOSI_CRT }} | |
EOF | |
echo -n ${{ github.ref_name }} > mkosi.version | |
mkosi --json summary|jq -r '.Images[-1]|{OUTPUT_DIR:.OutputDirectory,OUTPUT:.Output,IMAGE_ID:.ImageId}|to_entries|map("\(.key)=\(.value)\n")|join("")' >> $GITHUB_ENV | |
- name: Build images | |
run: mkosi build | |
- name: Test images | |
run: mkosi '--kernel-command-line-extra=systemd.run="echo hello"' qemu | |
- name: Compress outputs | |
if: startsWith(github.ref, 'refs/tags/') | |
run: xz -0 ${{ env.OUTPUT_DIR }}/${{ env.OUTPUT }}*.raw ${{ env.OUTPUT_DIR }}/${{ env.OUTPUT }}*.efi | |
- name: Generate SHA256SUMS | |
if: startsWith(github.ref, 'refs/tags/') | |
working-directory: ${{ env.OUTPUT_DIR }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
rename 's/\.([a-f0-9]{32})/_$1/' ${{ env.OUTPUT }}.*.*.raw.xz | |
sha256sum ${{ env.OUTPUT }}*.raw.xz ${{ env.OUTPUT }}*.efi.xz >> SHA256SUMS | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
fail_on_unmatched_files: true | |
generate_release_notes: true | |
files: | | |
${{ env.OUTPUT_DIR }}/${{ env.OUTPUT }}*.raw.xz | |
${{ env.OUTPUT_DIR }}/${{ env.OUTPUT }}*.efi.xz | |
${{ env.OUTPUT_DIR }}/SHA256SUMS | |
- name: Build cache | |
if: "!startsWith(github.ref, 'refs/tags/')" | |
run: sudo tar -cf mkosi.cache.tar.zst mkosi.cache --use-compress-program zstdmt | |
- name: Save cache | |
if: "steps.mkosi-cache.outputs.cache-hit != 'true' && !startsWith(github.ref, 'refs/tags/')" | |
uses: actions/cache/save@v4 | |
with: | |
path: mkosi.cache.tar.zst | |
key: mkosi-${{ hashFiles('mkosi.conf') }} |