From 82e3be9aa2813b60991fca5c00aee1866c0dbff8 Mon Sep 17 00:00:00 2001 From: docgalaxyblock Date: Sun, 20 Nov 2022 15:30:22 +0100 Subject: [PATCH] testing workflow improvements --- .github/workflows/BuildOS.yml | 79 ++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/.github/workflows/BuildOS.yml b/.github/workflows/BuildOS.yml index dc3c784..89ac4b5 100644 --- a/.github/workflows/BuildOS.yml +++ b/.github/workflows/BuildOS.yml @@ -31,7 +31,7 @@ jobs: shell: bash run: | sudo apt-get -qq update - sudo apt-get install --yes coreutils p7zip-full qemu-user-static zip + sudo apt-get install --yes aria2 coreutils p7zip-full qemu-user-static zip - name: Checkout CustomPiOS uses: actions/checkout@v3 @@ -43,30 +43,63 @@ jobs: uses: actions/checkout@v3 with: repository: ${{ github.repository }} - path: repository + path: OpenMowerOS submodules: true - - name: Download Raspberry Pi OS Source Image + - name: Base Image Checksum + id: checksum shell: bash - run: aria2c -d repository/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent + run: | + source OpenMowerOS/src/config + DIST_VERSION=$(date +"%Y.%m.%d") + cd OpenMowerOS/src/image + FILENAME=$(basename ${DOWNLOAD_URL_CHECKSUM}) + wget -O ${FILENAME} ${DOWNLOAD_URL_CHECKSUM} + FILE_CONTENT=$(head -n 1 $FILENAME) + CHECKSUM=$(echo $FILE_CONTENT | cut -d' ' -f1) + + echo "CHECKSUM=${CHECKSUM}" >> $GITHUB_OUTPUT + echo "FILENAME=${FILENAME}" >> $GITHUB_OUTPUT + + echo "DOWNLOAD_URL_IMAGE=${DOWNLOAD_URL_IMAGE}" >> $GITHUB_OUTPUT + + - name: Cache Base Source Image + id: cache + #if: + uses: actions/cache@v3 + with: + path: OpenMowerOS/src/image/*.img.xz + key: base-image-${{ steps.checksum.outputs.CHECKSUM }} + + - name: Download Base Source Image via Torrent + if: steps.cache.outputs.cache-hit != 'true' && endswith(steps.checksum.outputs.DOWNLOAD_URL_IMAGE, '.torrent') + shell: bash + run: aria2c -d OpenMowerOS/src/image --seed-time=0 ${{ steps.checksum.outputs.DOWNLOAD_URL_IMAGE }} + + - name: Download Base Source Image via wget + if: steps.cache.outputs.cache-hit != 'true' && !endswith(steps.checksum.outputs.DOWNLOAD_URL_IMAGE, '.torrent') + shell: bash + run: | + cd OpenMowerOS/src/image + wget ${{ steps.checksum.outputs.DOWNLOAD_URL_IMAGE }} - name: Comparing Checksums shell: bash run: | - cd repository/src/image - curl -JL https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256 | awk '{print $1" "$2}' | sha256sum -c + cd OpenMowerOS/src/image + sha256sum -b ${{ steps.checksum.outputs.FILENAME }} - name: Update CustomPiOS Paths shell: bash run: | - cd repository/src + cd OpenMowerOS/src ../../CustomPiOS/src/update-custompios-paths - name: Build Image shell: bash run: | sudo modprobe loop - cd repository/src + cd OpenMowerOS/src sudo bash -x ./build_dist sudo chown -R $USER ./ @@ -74,11 +107,11 @@ jobs: id: copy-image shell: bash run: | - source repository/src/config - NOW=$(date +"%Y-%m-%d-%Hh") - IMAGE="${NOW}_${DIST_NAME}-${DIST_VERSION}" + source OpenMowerOS/src/config + NOW=$(date +"%Y_%m_%d-%H_%M") + IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}" - cp repository/src/workspace/*.img $IMAGE.img + cp OpenMowerOS/src/workspace/*.img $IMAGE.img echo "image=${IMAGE}" >> $GITHUB_OUTPUT @@ -87,7 +120,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: build-failed-${{ steps.copy-image.outputs.image }}.log - path: repository/src/build.log + path: OpenMowerOS/src/build.log - name: Compress the image shell: bash @@ -118,4 +151,22 @@ jobs: uses: actions/upload-artifact@v3 with: name: ${{ steps.copy-image.outputs.image }}.img.sha256 - path: ${{ steps.copy-image.outputs.image }}.img.sha256 \ No newline at end of file + path: ${{ steps.copy-image.outputs.image }}.img.sha256 + + - name: Create latest Prerelease + uses: "marvinpinto/action-automatic-releases@v1.2.1" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + draft: false + prerelease: true + automatic_release_tag: latest + title: Latest Development Builds + files: | + ${{ steps.copy-image.outputs.image }}.img.xz + ${{ steps.copy-image.outputs.image }}.img.xz.sha256 + ${{ steps.copy-image.outputs.image }}.img.sha256 + + - name: Cleanup image artefacts + shell: bash + run: | + rm ${{ steps.copy-image.outputs.image }}* \ No newline at end of file