Skip to content

Commit

Permalink
testing workflow improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
docgalaxyblock committed Jul 31, 2023
1 parent 7ba7319 commit 0bdc00d
Showing 1 changed file with 95 additions and 20 deletions.
115 changes: 95 additions & 20 deletions .github/workflows/BuildOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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
Expand All @@ -45,15 +45,47 @@ jobs:
path: OpenMowerOS
submodules: true

- name: Download Raspberry Pi OS Source Image
- name: Base Image Checksum
id: checksum
shell: bash
run: aria2c -d OpenMowerOS/src/image/ --seed-time=0 https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent
run: |
source OpenMowerOS/src/config
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 OpenMowerOS/src/image
curl -JL https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256 | awk '{print $1" "$2}' | sha256sum -c
sha256sum -b ${{ steps.checksum.outputs.FILENAME }}
- name: Update CustomPiOS Paths
shell: bash
Expand All @@ -67,54 +99,97 @@ jobs:
sudo modprobe loop
cd OpenMowerOS/src
sudo bash -x ./build_dist
sudo chown -R $USER ./
- name: Copy output
id: copy-image
- name: Fix permissions
if: always()
shell: bash
run: |
sudo chown -R $USER:$USER ./
- name: Rename Image
id: rename-image
shell: bash
run: |
source OpenMowerOS/src/config
NOW=$(date +"%Y-%m-%d-%Hh")
IMAGE="${NOW}_${DIST_NAME}-${DIST_VERSION}"
NOW=$(date +"%Y_%m_%d-%H_%M")
IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}"
cp OpenMowerOS/src/workspace/*.img $IMAGE.img
WORKSPACE=$(echo ${{ github.workspace }})
sudo chown -R $USER:$USER $WORKSPACE/OpenMowerOS/src/workspace || true
sudo chmod 0775 -R $WORKSPACE/OpenMowerOS/src/workspace || true
mv OpenMowerOS/src/workspace/*.img $IMAGE.img
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
- name: Upload failed Logfile
if: failure()
uses: actions/upload-artifact@v3
with:
name: build-failed-${{ steps.copy-image.outputs.image }}.log
name: build-failed-${{ steps.rename-image.outputs.image }}.log
path: OpenMowerOS/src/build.log

- name: Compress the image
shell: bash
run: |
CPU_COUNT="$(nproc)"
echo -e "\e[32mUsing ${CPU_COUNT} Cores for compression...\e[0m"
xz -efkvz9T"${CPU_COUNT}" ${{ steps.copy-image.outputs.image }}.img
xz -efkvz9T"${CPU_COUNT}" ${{ steps.rename-image.outputs.image }}.img || true
- name: Calculating checksums
shell: bash
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
sha256sum ${{ steps.rename-image.outputs.image }}.img > ${{ steps.rename-image.outputs.image }}.img.sha256
sha256sum ${{ steps.rename-image.outputs.image }}.img.xz > ${{ steps.rename-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: ${{ steps.rename-image.outputs.image }}.img.xz
path: ${{ steps.rename-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
name: ${{ steps.rename-image.outputs.image }}.img.xz.sha256
path: ${{ steps.rename-image.outputs.image }}.img.xz.sha256

- name: Upload Image Checksum
uses: actions/upload-artifact@v3
with:
name: ${{ steps.copy-image.outputs.image }}.img.sha256
path: ${{ steps.copy-image.outputs.image }}.img.sha256
name: ${{ steps.rename-image.outputs.image }}.img.sha256
path: ${{ steps.rename-image.outputs.image }}.img.sha256

- name: Create "Latest Development Build" Pre-release
uses: "ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e"
with:
allowUpdates: true
#artifactErrorsFailBuild:
artifacts: |
${{ steps.rename-image.outputs.image }}.img.xz
${{ steps.rename-image.outputs.image }}.img.xz.sha256
${{ steps.rename-image.outputs.image }}.img.sha256
###body: Latest Development Build
#commit:
draft: false
generateReleaseNotes: false
#makeLatest: true
name: Latest Development Build
#omitBody: true
#omitBodyDuringUpdate: true
#omitDraftDuringUpdate: true
#omitName: true
#omitNameDuringUpdate: true
#omitPrereleaseDuringUpdate: true
prerelease: true
removeArtifacts: true
replacesArtifacts: true
skipIfReleaseExists: false
updateOnlyUnreleased: true
tag: latest
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Cleanup image artifacts
if: always()
shell: bash
run: |

0 comments on commit 0bdc00d

Please sign in to comment.