Skip to content

add: implement OpenMowerOS-Tools #66

add: implement OpenMowerOS-Tools

add: implement OpenMowerOS-Tools #66

Workflow file for this run

name: Build OpenMowerOS
on:
workflow_dispatch:
push:
branches:
- "**"
- "main"
paths:
- "src/**"
- ".github/workflows/BuildOS.yml"
tags-ignore:
- "**"
pull_request:
types: [opened, edited, reopened, synchronize]
paths:
- "src/**"
- ".github/workflows/BuildOS.yml"
# Allow to stop obsolete workflows
concurrency:
group: ci-buildtrain-${{ github.ref }}-1
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
shell: bash
run: |
sudo apt-get -qq update
sudo apt-get install --yes aria2 coreutils p7zip-full qemu-user-static zip
- name: Checkout CustomPiOS
uses: actions/checkout@v3
with:
repository: "guysoft/CustomPiOS"
path: CustomPiOS
- name: Checkout OpenMowerOS
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
path: OpenMowerOS
submodules: true
- name: Base Image Checksum
id: checksum
shell: bash
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
sha256sum -b ${{ steps.checksum.outputs.FILENAME }}
- name: Update CustomPiOS Paths
shell: bash
run: |
cd OpenMowerOS/src
../../CustomPiOS/src/update-custompios-paths
- name: Build Image
shell: bash
run: |
sudo modprobe loop
cd OpenMowerOS/src
sudo bash -x ./build_dist
- 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-%H_%M")
IMAGE="${NOW}-${DIST_NAME}-${DIST_VERSION}"
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.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.rename-image.outputs.image }}.img || true
- name: Calculating checksums
shell: bash
run: |
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.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.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.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: |