fix lepotato-raspbian build #1041
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
# Original: https://github.com/guysoft/OctoPi-Klipper-CustomPiOS/blob/6a88c12f562be4668e26fe89a445e761be1481ac/LICENSE | |
# License: GPL-3.0 | |
name: build images | |
on: | |
push: | |
branches: | |
- "build-*" | |
tags: | |
- "v*" | |
jobs: | |
# first, prepare the sources by moving the 'latest' tag to the current SHA | |
prepare: | |
runs-on: ubuntu-24.04 | |
steps: | |
# check the sources out in the 'expected place' for the following step that tags them | |
- name: Checkout Project Repository | |
uses: actions/checkout@v4 | |
with: | |
show-progress: false | |
- name: Check Python Code | |
run: | | |
cd src/modules/adsb-feeder/filesystem/root/opt/adsb/adsb-setup | |
python3 -m py_compile *.py | |
- name: tag current version as latest (regardless of other tags) | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: "latest" | |
tag_exists_error: false | |
force_push_tag: true | |
message: "latest commit" | |
# next run all the board builds | |
build: | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
name: [lepotato, lepotato-raspbian, nanopi-neo3-dietpi, orangepi-3lts-dietpi, orangepi-5plus-dietpi, orangepi-zero3-dietpi, raspberrypi64-pi-2-3-4-5, raspberrypi64-dietpi-pi-2-3-4, raspberrypi64-dietpi-pi-5, x86-64-native, x86-64-vm] | |
include: | |
- name: lepotato | |
base_arch: arm64 | |
variant: armbian | |
url: https://test.adsb.im/downloads/Armbian-unofficial_23.11.0-trunk_Lepotato_bookworm_current_6.1.63_minimal.img.xz | |
magic_path: "repository/src/image-armbian/le-potato.img.xz" | |
- name: lepotato-raspbian | |
base_arch: arm64 | |
variant: default | |
url: https://test.adsb.im/downloads/raspbian-bookworm-lepotato.img.xz | |
magic_path: "repository/src/image/le-potato-raspbian.img.xz" | |
- name: nanopi-neo3-dietpi | |
variant: dietpi-fat-2 | |
base_arch: arm64 | |
dietpi_machine: 56 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_NanoPiNEO3-ARMv8-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_NanoPiNEO3-ARMv8-Bookworm.img.xz" | |
- name: orangepi-3LTS-dietpi | |
variant: dietpi-fat-2 | |
base_arch: arm64 | |
dietpi_machine: 89 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_OrangePi3LTS-ARMv8-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_OrangePi3LTS-ARMv8-Bookworm.img.xz" | |
- name: orangepi-5plus-dietpi | |
variant: dietpi-fat-2 | |
base_arch: arm64 | |
dietpi_machine: 82 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_OrangePi5Plus-ARMv8-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_OrangePi5Plus-ARMv8-Bookworm.img.xz" | |
- name: orangepi-zero3-dietpi | |
variant: dietpi-fat-2 | |
base_arch: arm64 | |
dietpi_machine: 83 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_OrangePiZero3-ARMv8-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_OrangePiZero3-ARMv8-Bookworm.img.xz" | |
- name: raspberrypi64-pi-2-3-4-5 | |
base_arch: arm64 | |
variant: default | |
url: https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-10-28/2024-10-22-raspios-bookworm-arm64-lite.img.xz | |
magic_path: "repository/src/image/2024-03-15-raspios-bookworm-arm64-lite.img.xz" | |
- name: raspberrypi64-dietpi-pi-2-3-4 | |
base_arch: arm64 | |
variant: dietpi-fat-1 | |
dietpi_machine: 4 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_RPi234-ARMv8-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_RPi-ARMv8-Bookworm.img.xz" | |
- name: raspberrypi64-dietpi-pi-5 | |
base_arch: arm64 | |
variant: dietpi-fat-1 | |
dietpi_machine: 5 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_RPi5-ARMv8-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_RPi5-ARMv8-Bookworm.img.xz" | |
- name: x86-64-native | |
variant: dietpi-root-only | |
base_arch: x86_64 | |
dietpi_machine: 21 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_NativePC-BIOS-x86_64-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_NativePC-BIOS-x86_64-Bookworm.img.xz" | |
- name: x86-64-vm | |
variant: dietpi-root-only | |
base_arch: x86_64 | |
dietpi_machine: 20 | |
url: https://github.com/dirkhh/DietPi/releases/download/latest/DietPi_VM-x86_64-Bookworm.img.xz | |
magic_path: "repository/src/image-dietpi/DietPi_VM-x86_64-Bookworm.img.xz" | |
env: | |
IMG_NAME: ${{ matrix.name }} | |
BASE_ARCH: ${{ matrix.base_arch }} | |
VARIANT: ${{ matrix.variant }} | |
IMAGE_URL: ${{ matrix.url }} | |
MAGIC_PATH: ${{ matrix.magic_path }} | |
DIETPI_MACHINE: ${{ matrix.dietpi_machine }} | |
steps: | |
- name: mask secrets | |
run: | | |
echo "::add-mask::${{ secrets.USER_PASSWORD }}" | |
echo "::add-mask::${{ secrets.ROOT_PASSWORD }}" | |
echo "::add-mask::${{ secrets.SSH_KEY }}" | |
- name: Checkout Project Repository again with the new tag - and make sure we have the full history for the version code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
show-progress: false | |
path: repository | |
- name: Install Dependencies | |
run: | | |
sudo rm -f /var/lib/man-db/auto-update | |
sudo apt update | |
sudo apt-get install -y coreutils p7zip-full qemu-user-static qemu-utils lz4 | |
- name: Checkout CustomPiOS | |
uses: actions/checkout@v4 | |
with: | |
repository: 'dirkhh/CustomPiOS' | |
ref: 'adsbim' | |
show-progress: false | |
path: CustomPiOS | |
- name: Checkout DietPi | |
uses: actions/checkout@v4 | |
if: ${{ startsWith(env.VARIANT, 'dietpi') }} | |
with: | |
repository: dirkhh/DietPi | |
ref: adsbim | |
show-progress: false | |
path: DietPi | |
- name: Update CustomPiOS Paths and create image directories | |
run: | | |
cd repository/src | |
../../CustomPiOS/src/update-custompios-paths | |
mkdir -p image image-armbian image-dietpi | |
- name: Download image | |
run: | | |
MAGIC_DIR=$(dirname "${MAGIC_PATH}") | |
mkdir -p "${MAGIC_DIR}" | |
wget -qO "${MAGIC_PATH}" "$IMAGE_URL" | |
- name: create a reasonable tag for this run - either a short sha or the tag we were called with | |
id: tag | |
run: | | |
export tag="" | |
export is_release="test" | |
if [ "${{ github.ref_type }}" = "tag" ] ; then tag="${{ github.ref_name }}" ; else tag="${{ github.sha }}" ; fi | |
if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then is_release="release" ; fi | |
if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-beta ]] ; then is_release="beta" ; fi | |
export better_tag=$(echo $tag | sed -r 's/^(.{8}).{32}$/g-\1/') | |
echo "tag=${better_tag}" >> $GITHUB_OUTPUT | |
echo "is_release=${is_release}" >> $GITHUB_OUTPUT | |
- name: Build Image | |
id: build | |
run: | | |
if [[ ${IMG_NAME} == *x86-64-vm* ]] ; then | |
# this is where we run out of space. Bugger. | |
echo "remaining space before cleanup $(df -h .)" | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /usr/local/share/boost | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -f /var/lib/man-db/auto-update | |
sudo apt-get autoremove -y >/dev/null 2>&1 || true | |
sudo apt-get autoclean -y >/dev/null 2>&1 || true | |
echo "remaining space now $(df -h .)" | |
fi | |
sudo modprobe loop | |
cd repository/src | |
# if BASE_ARCH is set, add it to config | |
if [ -n "${BASE_ARCH}" ]; then | |
echo "export BASE_ARCH=${BASE_ARCH}" >> config | |
fi | |
feeder_image_name="adsb-im-${IMG_NAME}-${{ steps.tag.outputs.tag }}.img" | |
echo "export BASE_USER_PASSWORD=${{ secrets.USER_PASSWORD }}" >> config | |
echo "export ROOT_PWD=${{ secrets.ROOT_PASSWORD }}" >> config | |
echo "export SSH_PUB_KEY='${{ secrets.SSH_KEY }}'" >> config | |
echo "export FEEDER_IMAGE_NAME=${feeder_image_name}" >> config | |
echo "feeder_image_name=${feeder_image_name}" >> $GITHUB_OUTPUT | |
# make raspberry pi image as small as we can | |
if [[ ${IMG_NAME} == raspberrypi64-pi-2-3-4-5 ]] ; then | |
echo "export BASE_IMAGE_ENLARGEROOT=0" >> config | |
echo "export BASE_IMAGE_RESIZEROOT=50" >> config | |
fi | |
# finally, try one more time to have ALL the tags - to avoid weird errors in the code | |
# creating the version name - and also update `latest` in case that was wrong as well | |
git fetch --tags --force | |
sudo GH_REF_TYPE=${{ github.ref_type }} GH_TRGT_REF=${{ github.ref_name }} bash -x ./build_dist "${VARIANT}" | |
- name: Release Image | |
env: | |
BASE_RELEASE_COMPRESS: no | |
run: | | |
if [[ "${VARIANT}" = *"dietpi"* ]] ; then | |
echo "this doesn't do anything" | |
else | |
cd repository/src | |
# CUSTOM_PI_OS_PATH is needed, its set in build_dist. Setting here manually | |
export CUSTOM_PI_OS_PATH="$(realpath ../../CustomPiOS/src/)" | |
source config | |
sudo --preserve-env ../../CustomPiOS/src/release "${VARIANT}" | |
fi | |
- name: Copy output | |
id: copy | |
run: | | |
mkdir -p uploads | |
CURRENT_IMAGE_NAME="$(basename $MAGIC_PATH)" | |
echo "${CURRENT_IMAGE_NAME}" | |
IMAGE="${{ steps.build.outputs.feeder_image_name }}" | |
if [ "${VARIANT}" = "default" ]; then | |
WORKSPACE="repository/src/workspace" | |
elif [[ "${VARIANT}" = *"dietpi"* ]] ; then | |
WORKSPACE="repository/src/image-dietpi" | |
else | |
WORKSPACE="repository/src/workspace-${VARIANT}" | |
fi | |
ls -l "$WORKSPACE" | |
BUILT_IMAGE="$(find $WORKSPACE -name "*.img" | head -n 1)" | |
sudo mv -v "${BUILT_IMAGE}" uploads/"${IMAGE}" | |
if [[ ${IMG_NAME} == *x86-64-vm* ]] ; then | |
for img in $(find $WORKSPACE -name "DietPi_*.xz") ; do | |
base_name=$(basename "$img") | |
nodiet=${base_name#DietPi_} | |
nobookworm=${nodiet/-Bookworm/} | |
noarch=${nobookworm/-X86_64/} | |
echo "$img -> $nodiet -> $nobookworm -> $noarch" | |
final_name="adsb-im-x86-64-vm-${{ steps.tag.outputs.tag }}-${noarch}" | |
sudo mv -v "$img" uploads/"${final_name}" | |
done | |
fi | |
if [[ ${MAGIC_PATH} == *NativePC* ]] ; then | |
BUILT_ISO="$(find $WORKSPACE -name "*.iso" | head -n 1)" | |
sudo mv -v "${BUILT_ISO}" uploads/"${IMAGE%.img}.iso" | |
fi | |
- name: Compress img | |
id: compress | |
run: | | |
cd uploads | |
export IMAGE="${{ steps.build.outputs.feeder_image_name }}" | |
case ${IMAGE} in | |
*-x86-64-vm*) | |
NAME=${IMAGE%.img} | |
echo "name: ${NAME}" | |
cp ../repository/src/tools/pve-vmcreate.sh . | |
qemu-img convert -f raw ${IMAGE} -O qcow2 ${NAME}.qcow2 | |
XZ_OPT="-T0 --fast" tar cJf ${NAME}-proxmox.tar.xz ${NAME}.qcow2 pve-vmcreate.sh | |
echo "created tar file ${NAME}-proxmox.tar.xz" | |
ls -l ${NAME}-proxmox.tar.xz | |
sudo rm -f ${NAME}.qcow2 pve-vmcreate.sh | |
qemu-img convert -f raw "${IMAGE}" -O vmdk ${NAME}.vmdk | |
lz4 --fast --favor-decSpeed ${NAME}.vmdk ${NAME}.vmdk.lz4 | |
rm -f ${NAME}.vmdk | |
rm -f ${IMAGE} | |
ls -l ${NAME}* | |
echo "image=${NAME}*" >> $GITHUB_OUTPUT | |
;; | |
*) | |
echo "simply compress ${IMAGE}" | |
sudo xz -z -1 -T0 "${IMAGE}" | |
if [ -f ${IMAGE%.img}.iso ] ; then | |
sudo xz -z -1 -T0 ${IMAGE%.img}.iso | |
echo "image=${IMAGE%.img}.iso.xz" >> $GITHUB_OUTPUT | |
fi | |
echo "image=${IMAGE}.xz" >> $GITHUB_OUTPUT | |
;; | |
esac | |
ls -lh . | |
- name: Upload to GitHub as release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ steps.tag.outputs.is_release == 'release' }} | |
with: | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
generate_release_notes: true | |
body_path: repository/release-notes.md | |
files: uploads/* | |
- name: Upload to GitHub as beta release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ steps.tag.outputs.is_release == 'beta' }} | |
with: | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
generate_release_notes: true | |
body_path: repository/release-notes.md | |
prerelease: true | |
files: uploads/* | |
- name: Upload non-release artifacts | |
uses: softprops/action-gh-release@v2 | |
if: ${{ steps.tag.outputs.is_release == 'test' }} | |
with: | |
token: ${{ secrets.PAT_GITHUB_TOKEN }} | |
generate_release_notes: true | |
prerelease: true | |
tag_name: latest | |
name: testbuild-${{ steps.tag.outputs.tag }} | |
files: uploads/* |