-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build image function to GitHub Actions
This uses a script primarily written by Holger Friedrich with a few edits. Co-authored-by: Holger Friedrich <[email protected]> Signed-off-by: Ethan Dye <[email protected]>
- Loading branch information
Showing
6 changed files
with
148 additions
and
78 deletions.
There are no files selected for viewing
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Build Image | ||
|
||
# Trigger the workflow on push or pull request | ||
on: | ||
push: | ||
paths: | ||
- '**.bash' | ||
- '**.sh' | ||
- '!test.bash' | ||
pull_request: | ||
paths: | ||
- '**.bash' | ||
- '**.sh' | ||
- '!test.bash' | ||
|
||
jobs: | ||
build32: | ||
# Using latest Ubuntu (not the GitHub Actions default) to get latest tool versions in GitHub Actions environment | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Environment variables | ||
run: sudo -E bash -c set | ||
- name: Install required packages | ||
run: sudo apt-get install git wget unzip libarchive-zip-perl dos2unix xz-utils kpartx | ||
- name: Cache Raspberry Pi OS image | ||
id: cache-rasios32-image | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: cache-rasios32-image | ||
with: | ||
path: raspios_lite_armhf_latest.zip | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('raspios_lite_armhf_latest.zip') }} | ||
- name: Download Raspberry Pi OS image | ||
if: steps.cache-rasios32-image.outputs.cache-hit != 'true' | ||
run: wget -qO raspios_lite_armhf_latest.zip https://downloads.raspberrypi.org/raspios_lite_armhf_latest | ||
- name: Run build.bash rpi | ||
run: sudo -E ./build.bash rpi | ||
- name: getfilename | ||
id: getfilename | ||
run: echo "::set-output name=file::$(ls openhabian-*.img)" | ||
- name: Archive | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
# Artifact name | ||
name: ${{ steps.getfilename.outputs.file }} | ||
# Directory containing files to upload | ||
path: ${{ steps.getfilename.outputs.file }} | ||
build64experimental: | ||
# Using latest Ubuntu (not the GitHub Actions default) to get latest tool versions in GitHub Actions environment | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Environment variables | ||
run: sudo -E bash -c set | ||
- name: Install required packages | ||
run: sudo apt-get install git wget unzip libarchive-zip-perl dos2unix xz-utils kpartx | ||
- name: Cache Raspberry Pi OS image | ||
id: cache-rasios64-image | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: cache-rasios64-image | ||
with: | ||
path: raspios_lite_arm64_latest.zip | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('raspios_lite_arm64_latest.zip') }} | ||
- name: Download Raspberry Pi OS image | ||
if: steps.cache-rasios64-image.outputs.cache-hit != 'true' | ||
run: wget -qO raspios_lite_arm64_latest.zip https://downloads.raspberrypi.org/raspios_arm64_latest | ||
- name: Run build.bash rpi64 | ||
run: sudo -E ./build.bash rpi64 | ||
- name: getfilename | ||
id: getfilename | ||
run: echo "::set-output name=file::$(ls openhabian-*.img)" | ||
- name: Archive | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
# Artifact name | ||
name: ${{ steps.getfilename.outputs.file }} | ||
# Directory containing files to upload | ||
path: ${{ steps.getfilename.outputs.file }} |
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
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
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM balenalib/intel-nuc-ubuntu:focal-build | ||
FROM balenalib/amd64-ubuntu:focal-build | ||
|
||
|
||
ENV container docker | ||
|
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 file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,7 +212,7 @@ mkdir $buildfolder | |
if [ "$hw_platform" == "pi-raspios32" ] || [ "$hw_platform" == "pi-raspios64beta" ]; then | ||
if [ "$hw_platform" == "pi-raspios64beta" ]; then | ||
zipfile=raspios_lite_arm64_latest.zip | ||
baseurl="https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip" | ||
baseurl="https://downloads.raspberrypi.org/raspios_arm64_latest" | ||
bits=64 | ||
else | ||
zipfile=raspios_lite_armhf_latest.zip | ||
|
@@ -245,7 +245,8 @@ if [ "$hw_platform" == "pi-raspios32" ] || [ "$hw_platform" == "pi-raspios64beta | |
cp $zipfile "$buildfolder/$zipfile" | ||
else | ||
echo_process "Downloading latest Raspberry Pi OS ($bits-bit) Lite image (no local copy of $zipfile found)... " | ||
wget -nv -O "$buildfolder/$zipfile" "$baseurl" | ||
wget -qO "$zipfile" "$baseurl" | ||
cp $zipfile "$buildfolder/$zipfile" | ||
fi | ||
echo_process "Unpacking image... " | ||
unzip $buildfolder/$zipfile -d $buildfolder | ||
|
@@ -265,13 +266,10 @@ if [ "$hw_platform" == "pi-raspios32" ] || [ "$hw_platform" == "pi-raspios64beta | |
ln -s $buildfolder/root/etc/systemd/system/openhabian-installer.service $buildfolder/root/etc/systemd/system/multi-user.target.wants/openhabian-installer.service | ||
|
||
echo_process "Setting default runlevel multiuser.target... " | ||
( # open a subshell, returns to current dir automatically | ||
cd $buildfolder/root/etc/systemd/system/ || exit 1 | ||
rm -rf default.target | ||
ln -s ../../../lib/systemd/system/multi-user.target default.target | ||
# disable autologin | ||
rm -f $buildfolder/root/etc/systemd/system/[email protected]/autologin.conf | ||
) | ||
rm -rf $buildfolder/root/etc/systemd/system/default.target | ||
ln -s $buildfolder/lib/systemd/system/multi-user.target default.target | ||
# disable autologin | ||
rm -f $buildfolder/root/etc/systemd/system/[email protected]/autologin.conf | ||
|
||
touch $buildfolder/root/opt/openHABian-install-inprogress | ||
# maybe we should use a trap to get this done in case of error | ||
|
@@ -281,7 +279,8 @@ if [ "$hw_platform" == "pi-raspios32" ] || [ "$hw_platform" == "pi-raspios64beta | |
mount_image_file_boot "$imagefile" "$buildfolder" | ||
touch $buildfolder/boot/ssh | ||
cp $sourcefolder/first-boot.bash $buildfolder/boot/first-boot.bash | ||
sed -i -e '1r functions/helpers.bash' $buildfolder/boot/first-boot.bash # Add platform identification | ||
cp $sourcefolder/../functions/helpers.bash $buildfolder/boot/helpers.bash | ||
cp $sourcefolder/../functions/openhabian.bash $buildfolder/boot/openhabian.bash | ||
touch $buildfolder/boot/first-boot.log | ||
unix2dos -n $sourcefolder/openhabian.$hw_platform.conf $buildfolder/boot/openhabian.conf | ||
cp $sourcefolder/webif.bash $buildfolder/boot/webif.bash | ||
|
@@ -304,11 +303,13 @@ destination="openhabian-$hw_platform-$timestamp-git$file_tag$shorthash-crc$crc32 | |
mv -v $imagefile "$destination" | ||
rm -rf $buildfolder | ||
|
||
echo_process "Compressing image... " | ||
# speedup compression, T0 will use all cores and should be supported by reasonably new versions of xz | ||
xz --verbose --compress --keep -T0 "$destination" | ||
crc32checksum=$(crc32 "$destination.xz") | ||
mv "$destination.xz" "openhabian-$hw_platform-$timestamp-git$file_tag$shorthash-crc$crc32checksum.img.xz" | ||
if ! running_in_docker && ! running_on_github; then | ||
echo_process "Compressing image... " | ||
# speedup compression, T0 will use all cores and should be supported by reasonably new versions of xz | ||
xz --verbose --compress --keep -T0 "$destination" | ||
crc32checksum=$(crc32 "$destination.xz") | ||
mv "$destination.xz" "openhabian-$hw_platform-$timestamp-git$file_tag$shorthash-crc$crc32checksum.img.xz" | ||
fi | ||
|
||
echo_process "Finished! The results:" | ||
ls -alh "openhabian-$hw_platform-$timestamp"* | ||
|
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