diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed93ffc..df85ae0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,12 +6,18 @@ on: - cron: '0 0 * * *' jobs: + build_base: + uses: ./.github/workflows/build_base.yml build_nanodlp: + needs: build_base uses: ./.github/workflows/build_variant.yml with: variant: nanodlp-based + image_name: ${{ needs.build_base.outputs.image_name }} build_odyssey: + needs: build_base uses: ./.github/workflows/build_variant.yml with: variant: odyssey-based + image_name: ${{ needs.build_base.outputs.image_name }} diff --git a/.github/workflows/build_base.yml b/.github/workflows/build_base.yml new file mode 100644 index 0000000..73ea529 --- /dev/null +++ b/.github/workflows/build_base.yml @@ -0,0 +1,67 @@ +on: + workflow_call: + outputs: + image_name: + description: "The filename of the uploaded base image" + value: ${{ jobs.build.outputs.image_name }} + +jobs: + build: + runs-on: ubuntu-latest + outputs: + image_name: ${{ steps.artifact.outputs.image }} + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - name: Install Dependencies + run: | + sudo apt update + sudo apt install coreutils p7zip-full qemu-user-static + - name: Checkout CustomPiOS + uses: actions/checkout@v4 + with: + repository: 'guysoft/CustomPiOS' + path: CustomPiOS + ref: '70f1ae537a02195f1ba4f0a51ed381628e575c66' + + - name: Checkout Project Repository + uses: actions/checkout@v4 + with: + path: repository + submodules: true + + - name: Download Raspbian Image + run: | + cd repository/src/image + wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' + - name: Update CustomPiOS Paths + run: | + cd repository/src + ../../CustomPiOS/src/update-custompios-paths + + - name: Build Image + id: build + run: | + sudo modprobe loop + cd repository/src + sudo bash -x ./build_dist + + - name: Prepare artifact + id: artifact + run: | + source repository/src/config + NOW=$(date +"%Y-%m-%d-%H%M") + IMAGE=$NOW-prometheusos-BASE-$DIST_VERSION + cp repository/src/workspace/*.img $IMAGE.img + tar -cJf $IMAGE.img.xz $IMAGE.img + echo "image=$IMAGE" >> $GITHUB_OUTPUT + echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT + + - uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact.outputs.image }} + path: ${{ steps.artifact.outputs.image }}.img.xz diff --git a/.github/workflows/build_variant.yml b/.github/workflows/build_variant.yml index bb4964d..c40da2a 100644 --- a/.github/workflows/build_variant.yml +++ b/.github/workflows/build_variant.yml @@ -4,11 +4,20 @@ on: variant: required: true type: string + image_name: + required: true + type: string jobs: build: runs-on: ubuntu-latest steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Install Dependencies run: | sudo apt update @@ -21,15 +30,17 @@ jobs: ref: '70f1ae537a02195f1ba4f0a51ed381628e575c66' - name: Checkout Project Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: repository submodules: true - - name: Download Raspbian Image - run: | - cd repository/src/image - wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' + - name: Download base image + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.image_name }} + path: repository/src/image + - name: Update CustomPiOS Paths run: | cd repository/src @@ -49,7 +60,7 @@ jobs: NOW=$(date +"%Y-%m-%d-%H%M") IMAGE=$NOW-prometheusos-${{ inputs.variant }}-$DIST_VERSION cp repository/src/workspace-${{ inputs.variant }}/*.img $IMAGE.img - tar -czvf $IMAGE.tar.gz $IMAGE.img + tar -cJf $IMAGE.img.xz $IMAGE.img echo "image=$IMAGE" >> $GITHUB_OUTPUT echo "dist_version=$DIST_VERSION" >> $GITHUB_OUTPUT @@ -62,7 +73,7 @@ jobs: uses: ncipollo/release-action@v1 if: github.ref == 'refs/heads/main' with: - artifacts: ${{ steps.compress.outputs.image }}.tar.gz + artifacts: ${{ steps.compress.outputs.image }}.img.xz tag: v${{ steps.compress.outputs.dist_version }} skipIfReleaseExists: true omitBodyDuringUpdate: true diff --git a/src/config b/src/config index 4d8226e..07779ce 100644 --- a/src/config +++ b/src/config @@ -16,7 +16,7 @@ export BASE_RELEASE_IMAGE_NAME="PrometheusOS" # Prometheus Settings export KLIPPER_REPO_SHIP="https://github.com/TheContrappostoShop/klipper.git" -export MODULES="base(pkgupgrade,network,klipper,nanodlp,odyssey,prometheus_config,openocd)" +export MODULES="base(pkgupgrade,network,auto-mount-removable,klipper,prometheus_config,openocd,user_rename)" # Prevent known wifi issues export NETWORK_DISABLE_PWRSAVE=no diff --git a/src/modules/prometheus_config/start_chroot_script b/src/modules/prometheus_config/start_chroot_script index ca2bff1..6bf2d28 100644 --- a/src/modules/prometheus_config/start_chroot_script +++ b/src/modules/prometheus_config/start_chroot_script @@ -23,14 +23,16 @@ for dir in ${PROMETHEUS_CONFIG_DIRS}; do sudo -u "${BASE_USER}" mkdir -p "${dir}" done -sudo -u "${BASE_USER}" cp prometheus_config/klipper/.config klipper/ -sudo -u "${BASE_USER}" cp prometheus_config/klipper/config/* printer_data/config/ +sudo -u "${BASE_USER}" mv prometheus_config/klipper/.config klipper/ +sudo -u "${BASE_USER}" mv prometheus_config/klipper/config/* printer_data/config/ # Only copy nanodlp files if neccessary if [[ $MODULES == *"nanodlp"* ]]; then - sudo -u "${BASE_USER}" cp prometheus_config/nanodlp/* nanodlp/db/ + sudo -u "${BASE_USER}" mv prometheus_config/nanodlp/* nanodlp/db/ fi +sudo -u "${BASE_USER}" rm -rf prometheus_config + # if Odyssey is included in this build, then include the relevant klipper config # at the head of printer.cfg if [[ $MODULES == *"odyssey"* ]]; then diff --git a/src/variants/nanodlp-based/config b/src/variants/nanodlp-based/config index b5fca96..42d6c51 100644 --- a/src/variants/nanodlp-based/config +++ b/src/variants/nanodlp-based/config @@ -1 +1,2 @@ -export MODULES="base(pkgupgrade,network,klipper,nanodlp,prometheus_config,openocd,user_rename)" \ No newline at end of file +export MODULES="base(nanodlp)" +export BASE_ZIP_IMG=$(ls -t ${DIST_PATH}/image/*.xz | head -n 1) \ No newline at end of file diff --git a/src/variants/odyssey-based/config b/src/variants/odyssey-based/config index c52d568..55ed7b0 100644 --- a/src/variants/odyssey-based/config +++ b/src/variants/odyssey-based/config @@ -1 +1,2 @@ -export MODULES="base(pkgupgrade,network,auto-mount-removable,klipper,moonraker,mainsail,odyssey,prometheus_config,openocd,user_rename)" \ No newline at end of file +export MODULES="base(moonraker,mainsail,odyssey)" +export BASE_ZIP_IMG=$(ls -t ${DIST_PATH}/image/*.xz | head -n 1) \ No newline at end of file