Build Image from Repo #15
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 Image from Repo | |
on: | |
workflow_dispatch: | |
inputs: | |
architecture: | |
description: 'ARM architecture: armv6l/aarch64' | |
tagCustomPiOS: | |
default: '' | |
description: 'Optional tag of CustomPiOS' | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
env: | |
HYPERHDR_DEB: 'https://github.com/awawa-dev/HyperHDR/releases/download/v${{ github.event.inputs.tags }}/HyperHDR-${{ github.event.inputs.tags }}-Linux-${{ github.event.inputs.architecture }}.deb' | |
steps: | |
- name: Install Dependencies | |
run: | | |
sudo apt update | |
sudo apt install coreutils p7zip-full qemu-user-static xz-utils | |
- name: Checkout CustomPiOS | |
uses: actions/checkout@v4 | |
with: | |
repository: 'guysoft/CustomPiOS' | |
ref: '${{ github.event.inputs.tagCustomPiOS }}' | |
path: CustomPiOS | |
- name: Prepare HyperHDR module | |
run: | | |
cd CustomPiOS | |
sudo bash -x src/make_custom_pi_os HyperHDR | |
sudo chown -R runner HyperHDR | |
- name: Download Raspbian Image (32-bits) | |
if: github.event.inputs.architecture != 'aarch64' | |
run: | | |
mkdir -p CustomPiOS/HyperHDR/src/image | |
cd CustomPiOS/HyperHDR/src/image | |
wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf-lite.img.xz' | |
echo "workspace_dir=CustomPiOS/HyperHDR/src/workspace" >> $GITHUB_ENV | |
- name: Download Raspbian Image (64-bits) | |
if: github.event.inputs.architecture == 'aarch64' | |
run: | | |
mkdir -p CustomPiOS/HyperHDR/src/image-raspios_lite_arm64 | |
cd CustomPiOS/HyperHDR/src/image-raspios_lite_arm64 | |
wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-05-03/2023-05-03-raspios-bullseye-arm64-lite.img.xz' | |
echo "workspace_dir=CustomPiOS/HyperHDR/src/workspace-raspios_lite_arm64" >> $GITHUB_ENV | |
echo "workspace_variant=raspios_lite_arm64" >> $GITHUB_ENV | |
- name: Update HyperHDR modules | |
run: | | |
cd CustomPiOS/HyperHDR/src | |
echo 'export DIST_NAME=HyperHDR' > config | |
echo 'export DIST_VERSION=${{ github.event.inputs.tags }}' >> config | |
echo 'export MODULES="base(network,hyperhdr)"' >> config | |
echo 'export RPI_IMAGER_NAME="${DIST_NAME} version ${DIST_VERSION}"' >> config | |
echo 'export RPI_IMAGER_DESCRIPTION="A Raspberry Pi distribution for ambient lighting. Ships HyperHDR out-of-the-box."' >> config | |
echo 'export RPI_IMAGER_ICON="https://github.com/awawa-dev/HyperHDR/blob/master/resources/icons/hyperhdr-icon-32px.png"' >> config | |
echo 'export BASE_IMAGE_ENLARGEROOT=2000' >> config | |
echo 'export BASE_IMAGE_RESIZEROOT=200' >> config | |
cd modules/hyperhdr | |
echo '#!/usr/bin/env bash' > start_chroot_script | |
echo 'set -x' >> start_chroot_script | |
echo 'set -e' >> start_chroot_script | |
echo 'source /common.sh' >> start_chroot_script | |
echo 'type -p curl >/dev/null || apt install curl -y' >> start_chroot_script | |
echo 'curl -fsSL https://awawa-dev.github.io/hyperhdr.public.apt.gpg.key | dd of=/usr/share/keyrings/hyperhdr.public.apt.gpg.key \' >> start_chroot_script | |
echo '&& chmod go+r /usr/share/keyrings/hyperhdr.public.apt.gpg.key \' >> start_chroot_script | |
echo '&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hyperhdr.public.apt.gpg.key] https://awawa-dev.github.io $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hyperhdr.list > /dev/null \' >> start_chroot_script | |
echo '&& apt update \' >> start_chroot_script | |
echo '&& apt install --only-upgrade udev -y \' >> start_chroot_script | |
echo '&& apt install hyperhdr -y' >> start_chroot_script | |
echo 'touch /boot/ssh' >> start_chroot_script | |
echo "echo -n 'pi:' > /boot/userconf" >> start_chroot_script | |
echo "echo 'raspberry' | openssl passwd -6 -stdin >> /boot/userconf" >> start_chroot_script | |
echo 'echo "HyperHDR" > /etc/hostname' >> start_chroot_script | |
echo 'sed -i "s/raspberrypi/HyperHDR/" /etc/hosts' >> start_chroot_script | |
echo "systemctl -q enable hyperhdr@pi.service" >> start_chroot_script | |
echo 'sed -i "s/^#dtparam=spi=on.*/dtparam=spi=on/" /boot/config.txt' >> start_chroot_script | |
echo 'sed -i "s/^#hdmi_force_hotplug=1.*/hdmi_force_hotplug=1/" /boot/config.txt' >> start_chroot_script | |
chmod +x start_chroot_script | |
- name: Build HyperHDR Raspbian Image | |
run: | | |
sudo modprobe loop | |
cd CustomPiOS/HyperHDR | |
sudo bash -x src/build_dist ${{ env.workspace_variant }} | |
- name: Copy output | |
id: copy | |
run: | | |
IMAGE=SD-card-image-${{ github.event.inputs.tags }}-${{ github.event.inputs.architecture }} | |
cp ${{ env.workspace_dir }}/*.img $IMAGE.img | |
xz -v9 $IMAGE.img | |
echo "image=$IMAGE" >> $GITHUB_OUTPUT | |
# artifact upload will take care of zipping for us | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.copy.outputs.image }} | |
path: ${{ steps.copy.outputs.image }}.img.xz |