forked from awawa-dev/HyperHDR
-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (113 loc) · 5.94 KB
/
image-builder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Build Image
on:
workflow_dispatch:
inputs:
tags:
description: 'HyperHDR release tag (for example 17.0.0.0)'
architecture:
description: 'ARM architecture: armv6l/aarch64'
tagCustomPiOS:
default: ''
description: 'Optional tag of CustomPiOS'
debian:
default: ''
description: 'optional Debian version'
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: Overrride Debian download link
if: github.event.inputs.debian != ''
run: |
tag_name="${{ github.event.inputs.tags }}"
first_version="${tag_name%beta*}"
second_version="${tag_name#*beta}"
[ ${first_version} != ${second_version} ] && second_version="~beta${second_version}"
[ ${first_version} == ${second_version} ] && second_version=""
echo "HYPERHDR_DEB='https://github.com/awawa-dev/HyperHDR/releases/download/v${{ github.event.inputs.tags }}/HyperHDR_${first_version}~${{ github.event.inputs.debian }}${second_version}_${{ github.event.inputs.architecture }}.deb'" >> $GITHUB_ENV
- name: Install Dependencies
run: |
sudo apt update
sudo apt install coreutils p7zip-full qemu-user-static
- name: Checkout CustomPiOS
uses: actions/[email protected]
with:
repository: 'guysoft/CustomPiOS'
path: CustomPiOS
- name: Select CustomPiOS version
if: github.event.inputs.tagCustomPiOS != ''
run: |
cd CustomPiOS
git reset --hard ${{ github.event.inputs.tagCustomPiOS }}
- 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_latest'
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_latest'
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-get update' >> start_chroot_script
echo 'cd /tmp' >> start_chroot_script
echo 'wget ${{env.HYPERHDR_DEB}} -O hyperhdr.deb' >> start_chroot_script
echo 'apt install -y ./hyperhdr.deb' >> start_chroot_script
echo 'rm ./hyperhdr.deb' >> 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 [email protected]" >> 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
echo "image=$IMAGE" >> $GITHUB_OUTPUT
# artifact upload will take care of zipping for us
- uses: actions/[email protected]
with:
name: ${{ steps.copy.outputs.image }}
path: ${{ steps.copy.outputs.image }}.img