diff --git a/.github/workflows/self_hosted_patch.yml b/.github/workflows/self_hosted_patch.yml index 65ba39a..dda09c9 100644 --- a/.github/workflows/self_hosted_patch.yml +++ b/.github/workflows/self_hosted_patch.yml @@ -387,4 +387,143 @@ jobs: sudo rm chr-$LATEST_VERSION$ARCH.vhdx sudo rm chr-$LATEST_VERSION$ARCH.vdi sudo rm chr-$LATEST_VERSION$ARCH.img + + + - name: Cache refind + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' + id: cache-refind + uses: actions/cache@v4 + with: + path: refind-bin-0.14.2.zip + key: refind + + - name: Get refind + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true' + run: sudo wget -nv -O refind-bin-0.14.2.zip https://nchc.dl.sourceforge.net/project/refind/0.14.2/refind-bin-0.14.2.zip + + - name: Create install-image-${{ env.LATEST_VERSION }}.img + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' + run: | + sudo modprobe nbd + sudo apt-get install -y qemu-utils extlinux > /dev/null + truncate --size 128M install-image-$LATEST_VERSION.img + sudo qemu-nbd -c /dev/nbd0 -f raw install-image-$LATEST_VERSION.img + sudo mkfs.vfat -n "Install" /dev/nbd0 + sudo mkdir ./install + sudo mount /dev/nbd0 ./install + sudo mkdir -p ./install/EFI/BOOT + sudo unzip refind-bin-0.14.2.zip refind-bin-0.14.2/refind/refind_x64.efi + sudo cp refind-bin-0.14.2/refind/refind_x64.efi ./install/EFI/BOOT/BOOTX64.EFI + sudo rm -rf refind-bin-0.14.2 + echo -e 'timeout 0\ntextonly\ntextmode 0\nshowtools shutdown, reboot, exit\nmenuentry "Install RouterOS" {\n\tloader /linux\n\toptions "load_ramdisk=1 root=/dev/ram0 -install -hdd"\n}\ndefault_selection /EFI/BOOT/BOOTX64.EFI' \ + > refind.conf + sudo cp refind.conf ./install/EFI/BOOT/ + sudo rm refind.conf + sudo extlinux --install -H 64 -S 32 ./install/ + echo -e 'default system\nLABEL system\n\tKERNEL linux\n\tAPPEND load_ramdisk=1 -install -hdd' \ + > syslinux.cfg + sudo cp syslinux.cfg ./install/ + sudo rm syslinux.cfg + sudo cp ./BOOTX64.EFI ./install/linux + NPK_FILES=($(find ./all_packages/*.npk)) + for ((i=1; i<=${#NPK_FILES[@]}; i++)) + do + echo "${NPK_FILES[$i-1]}=>$i.npk" + sudo cp ${NPK_FILES[$i-1]} ./install/$i.npk + done + sudo touch ./install/CHOOSE + sudo touch ./install/autorun.scr + sudo umount /dev/nbd0 + sudo qemu-nbd -d /dev/nbd0 + sudo rm -rf ./install + sudo zip install-image-$LATEST_VERSION.zip ./install-image-$LATEST_VERSION.img + sudo rm ./install-image-$LATEST_VERSION.img + + - name: Cache NetInstall ${{ env.LATEST_VERSION }} + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' + id: cache-netinstall + uses: actions/cache@v4 + with: + path: | + netinstall.zip + netinstall.tar.gz + key: netinstall-${{ env.LATEST_VERSION }} + + - name: Get netinstall ${{ env.LATEST_VERSION }} + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true' + run: | + sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip + sudo wget -nv -O netinstall.tar.gz https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.tar.gz + + - name: Patch netinstall ${{ env.LATEST_VERSION }} + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.get_latest.outputs.has_patched_npk == 'true' + run: | + sudo unzip netinstall.zip + sudo -E python3 patch.py netinstall netinstall.exe + sudo zip netinstall-$LATEST_VERSION.zip ./netinstall.exe + sudo tar -xvf netinstall.tar.gz + sudo -E python3 patch.py netinstall netinstall-cli + sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli + + - name: Upload Files + if: steps.get_latest.outputs.has_new_version == 'true' + run: | + sudo mkdir -p ./publish/$LATEST_VERSION + sudo cp CHANGELOG ./publish/$LATEST_VERSION/ + sudo cp ./all_packages/*.npk ./publish/$LATEST_VERSION/ + sudo chown -R root:root ./publish/ + sudo apt-get install -y lftp ssh sshpass > /dev/null 2>&1 + sudo -E lftp -u ${{ secrets.SSH_USERNAME }},'${{ secrets.SSH_PASSWORD }}' sftp://${{ secrets.SSH_SERVER }}:${{ secrets.SSH_PORT }} <