From bf3e96f6a2c6701d9aa98172c0f436f3f6829f87 Mon Sep 17 00:00:00 2001 From: hzy Date: Wed, 27 Jul 2022 03:21:16 +0800 Subject: [PATCH] GHA: Generate burn image --- .github/workflows/ci.yml | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9b7506d0d2c..13dcc59255fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,11 @@ jobs: with: repository: armbian/build + - name: "Apply patch #3981" + run: | + curl -L -O https://github.com/armbian/build/pull/3981.patch + git apply 3981.patch + - name: Build run: | sudo ./compile.sh \ @@ -60,7 +65,62 @@ jobs: EXPERT=yes \ USE_CCACHE=no \ NO_APT_CACHER=yes \ - COMPRESS_OUTPUTIMAGE=xz,sha,gpg + COMPRESS_OUTPUTIMAGE=img,xz,sha,gpg + sudo chown $(id -u):$(id -g) -R output/ + + - name: Download AmlImg + run: | + ver="v0.3.0" + curl -L -o ./AmlImg https://github.com/hzyitc/AmlImg/releases/download/$ver/AmlImg_${ver}_linux_amd64 + chmod +x ./AmlImg + + - name: Download and unpack the latest u-boot + run: | + echo "::group::Download" + tag=$(curl https://api.github.com/repos/hzyitc/u-boot-onecloud/releases/latest | jq -r .tag_name) + curl -L -o ./uboot.img https://github.com/hzyitc/u-boot-onecloud/releases/download/$tag/eMMC.burn.img + echo "::endgroup::" + + echo "::group::Unpack" + ./AmlImg unpack ./uboot.img burn/ + echo "::endgroup::" + + - name: Extract boot and rootfs partitions + run: | + diskimg=$(ls output/images/*.img) + loop=$(sudo losetup --find --show --partscan $diskimg) + sudo dd if=${loop}p1 of=burn/boot.img + sudo dd if=${loop}p2 of=burn/rootfs.img + sudo losetup -d $loop + sudo chown $(id -u):$(id -g) -R burn/ + + - name: Generate burn image + run: | + echo -n "sha1sum $(sha1sum burn/boot.img | awk '{print $1}')" >burn/boot.VERIFY + echo -n "sha1sum $(sha1sum burn/rootfs.img | awk '{print $1}')" >burn/rootfs.VERIFY + + cat <>burn/commands.txt + PARTITION:boot:normal:boot.img + VERIFY:boot:normal:boot.VERIFY + PARTITION:rootfs:normal:rootfs.img + VERIFY:rootfs:normal:rootfs.VERIFY + EOF + + prefix=$(ls output/images/*.img | sed 's/\.img$//') + burnimg=${prefix}.burn.img + ./AmlImg pack $burnimg burn/ + + - name: Hash and compress burn image + run: | + cd output/images/ + burnimg=$(ls *.burn.img) + sha256sum $burnimg | tee ${burnimg}.sha + + pixz -9 <$burnimg >${burnimg}.xz + + - name: Clean original files + run: | + rm -rf output/images/*.img - name: Upload artifacts uses: actions/upload-artifact@v2