From 17dbbe99d65e6f424d8feb1683b0259e9bbdda12 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 6 Sep 2022 19:56:13 +0200 Subject: [PATCH 1/2] chore: add github runner cache to ReleaseRaspiOS.yml Signed-off-by: Stefan Dej --- .github/workflows/ReleaseRaspiOS.yml | 30 ++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ReleaseRaspiOS.yml b/.github/workflows/ReleaseRaspiOS.yml index b7b9067df..875616e8a 100644 --- a/.github/workflows/ReleaseRaspiOS.yml +++ b/.github/workflows/ReleaseRaspiOS.yml @@ -3,18 +3,23 @@ on: release: types: [ published ] +env: + DOWNLOAD_URL_CHECKSUM: "https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" + DOWNLOAD_URL_IMAGE: "https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" + FILENAME_CHECKSUM: "raspios_lite_armhf_latest.sha256" + jobs: raspiosbuild: runs-on: ubuntu-latest steps: - name: Install Dependencies - run: sudo apt install coreutils p7zip-full qemu-user-static zip + run: sudo apt update; sudo apt install --yes coreutils p7zip-full qemu-user-static zip - name: Checkout CustomPiOS uses: actions/checkout@v2 with: - repository: 'guysoft/CustomPiOS' + repository: "guysoft/CustomPiOS" path: CustomPiOS - name: Checkout MainsailOS Project @@ -24,13 +29,30 @@ jobs: path: repository submodules: true + - name: Raspberry Pi OS Checksum + id: raspios-checksum + run: | + cd repository/src/image + wget -O $FILENAME_CHECKSUM $DOWNLOAD_URL_CHECKSUM + FILE_CONTENT=$(head -n 1 $FILENAME_CHECKSUM) + CHECKSUM=$(echo $FILE_CONTENT | cut -d' ' -f1) + echo "::set-output name=CHECKSUM::$CHECKSUM" + + - name: Cache Raspberry Pi OS Source Image + id: cache-source-image + uses: actions/cache@v3 + with: + path: repository/src/image/*.img.xz + key: ${{ runner.os }}-${{ steps.raspios-checksum.outputs.CHECKSUM }} + - name: Download Raspberry Pi OS Source Image - run: aria2c -d repository/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf_latest.torrent + if: steps.cache-source-image.outputs.cache-hit != 'true' + run: aria2c -d repository/src/image --seed-time=0 $DOWNLOAD_URL_IMAGE - name: Comparing Checksums run: | cd repository/src/image - curl -JL https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf_latest.sha256 | awk '{print $1" "$2}' | sha256sum -c + cat $FILENAME_CHECKSUM | awk '{print $1" "$2}' | sha256sum -c - name: Update CustomPiOS Paths run: cd repository/src && ../../CustomPiOS/src/update-custompios-paths From 4c3b75ccc295af4f96eae7b2891dc778d10e0d08 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 6 Sep 2022 19:56:23 +0200 Subject: [PATCH 2/2] chore: add github runner cache to BuildRaspiOS.yml Signed-off-by: Stefan Dej --- .github/workflows/BuildRaspiOS.yml | 72 ++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 9 deletions(-) diff --git a/.github/workflows/BuildRaspiOS.yml b/.github/workflows/BuildRaspiOS.yml index e8bd97ed3..ff83c91df 100644 --- a/.github/workflows/BuildRaspiOS.yml +++ b/.github/workflows/BuildRaspiOS.yml @@ -18,6 +18,17 @@ on: workflow_dispatch: + +# Allow to stop obsolete workflows +concurrency: + group: ci-buildraspios-${{ github.ref }}-1 + cancel-in-progress: true + +env: + DOWNLOAD_URL_CHECKSUM: "https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256" + DOWNLOAD_URL_IMAGE: "https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent" + FILENAME_CHECKSUM: "raspios_lite_armhf_latest.sha256" + jobs: raspiosbuild: runs-on: ubuntu-latest @@ -39,13 +50,30 @@ jobs: path: repository submodules: true + - name: Raspberry Pi OS Checksum + id: raspios-checksum + run: | + cd repository/src/image + wget -O $FILENAME_CHECKSUM $DOWNLOAD_URL_CHECKSUM + FILE_CONTENT=$(head -n 1 $FILENAME_CHECKSUM) + CHECKSUM=$(echo $FILE_CONTENT | cut -d' ' -f1) + echo "::set-output name=CHECKSUM::$CHECKSUM" + + - name: Cache Raspberry Pi OS Source Image + id: cache-source-image + uses: actions/cache@v3 + with: + path: repository/src/image/*.img.xz + key: ${{ runner.os }}-${{ steps.raspios-checksum.outputs.CHECKSUM }} + - name: Download Raspberry Pi OS Source Image - run: aria2c -d repository/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf_latest.torrent + if: steps.cache-source-image.outputs.cache-hit != 'true' + run: aria2c -d repository/src/image --seed-time=0 $DOWNLOAD_URL_IMAGE - name: Comparing Checksums run: | cd repository/src/image - curl -JL https://downloads.raspberrypi.org/raspios_oldstable_lite_armhf_latest.sha256 | awk '{print $1" "$2}' | sha256sum -c + cat $FILENAME_CHECKSUM | awk '{print $1" "$2}' | sha256sum -c - name: Update CustomPiOS Paths run: cd repository/src && ../../CustomPiOS/src/update-custompios-paths @@ -53,13 +81,39 @@ jobs: - name: Build Image run: sudo modprobe loop && cd repository/src && sudo bash -x ./build_dist - - name: Copy output image - run: cp ${{ github.workspace }}/repository/src/workspace/*-raspios-*-lite.img mainsailos-raspios-lite-latest.img + - name: Copy output + id: copy-image + run: | + source repository/src/config + NOW=$(date +"%Y-%m-%d") + IMAGE=$NOW-mainsailos-$DIST_VERSION - - name: Compress the image - run: zip mainsailos-raspios-lite-latest.zip mainsailos-raspios-lite-latest.img + cp repository/src/workspace/*.img $IMAGE.img + + echo "::set-output name=image::$IMAGE" + + - name: Compressing Image + run: xz -efkvz ${{ steps.copy-image.outputs.image }}.img + + - name: Calculating checksums + run: | + sha256sum ${{ steps.copy-image.outputs.image }}.img > ${{ steps.copy-image.outputs.image }}.img.sha256 + sha256sum ${{ steps.copy-image.outputs.image }}.img.xz > ${{ steps.copy-image.outputs.image }}.img.xz.sha256 + + - name: Upload Compressed Image + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.copy-image.outputs.image }}.img.xz + path: ${{ steps.copy-image.outputs.image }}.img.xz + + - name: Upload Compressed Image Checksum + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.copy-image.outputs.image }}.img.xz.sha256 + path: ${{ steps.copy-image.outputs.image }}.img.xz.sha256 - - uses: actions/upload-artifact@v2 + - name: Upload Image Checksum + uses: actions/upload-artifact@v3 with: - name: mainsailos-raspios-lite-latest.zip - path: mainsailos-raspios-lite-latest.zip + name: ${{ steps.copy-image.outputs.image }}.img.sha256 + path: ${{ steps.copy-image.outputs.image }}.img.sha256