2024-07-19 05:15:57 +03:00
|
|
|
name: Patch Mikrotik RouterOS 7.x
|
2024-06-15 02:18:14 +03:00
|
|
|
on:
|
|
|
|
# push:
|
|
|
|
# branches: [ "main" ]
|
|
|
|
schedule:
|
|
|
|
- cron: "0 0 * * *"
|
|
|
|
workflow_dispatch:
|
2024-06-29 23:39:08 +03:00
|
|
|
|
2024-06-15 02:18:14 +03:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
|
|
|
|
jobs:
|
2024-07-19 05:15:57 +03:00
|
|
|
Patch_RouterOS:
|
2024-07-03 07:05:38 +03:00
|
|
|
runs-on: ubuntu-22.04
|
2024-06-18 12:22:20 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-07-19 05:15:57 +03:00
|
|
|
arch: [x86,arm64]
|
2024-06-18 12:22:20 +03:00
|
|
|
channel: [stable, testing]
|
2024-06-15 02:18:14 +03:00
|
|
|
env:
|
|
|
|
TZ: 'Asia/Shanghai'
|
2024-06-18 12:22:20 +03:00
|
|
|
LATEST_VERSION: ""
|
2024-07-02 05:12:24 +03:00
|
|
|
BUILD_TIME: "0"
|
2024-07-12 01:09:52 +03:00
|
|
|
ARCH: ""
|
2024-06-15 02:18:14 +03:00
|
|
|
CUSTOM_LICENSE_PRIVATE_KEY: ${{ secrets.CUSTOM_LICENSE_PRIVATE_KEY }}
|
|
|
|
CUSTOM_LICENSE_PUBLIC_KEY: ${{ secrets.CUSTOM_LICENSE_PUBLIC_KEY }}
|
|
|
|
CUSTOM_NPK_SIGN_PRIVATE_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PRIVATE_KEY }}
|
|
|
|
CUSTOM_NPK_SIGN_PUBLIC_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PUBLIC_KEY }}
|
|
|
|
MIKRO_LICENSE_PUBLIC_KEY: ${{ secrets.MIKRO_LICENSE_PUBLIC_KEY }}
|
|
|
|
MIKRO_NPK_SIGN_PUBLIC_LKEY: ${{ secrets.MIKRO_NPK_SIGN_PUBLIC_LKEY }}
|
2024-07-01 17:46:00 +03:00
|
|
|
MIKRO_LICENCE_URL: ${{ secrets.MIKRO_LICENCE_URL }}
|
|
|
|
CUSTOM_LICENCE_URL: ${{ secrets.CUSTOM_LICENCE_URL }}
|
|
|
|
MIKRO_UPGRADE_URL: ${{ secrets.MIKRO_UPGRADE_URL }}
|
|
|
|
CUSTOM_UPGRADE_URL: ${{ secrets.CUSTOM_UPGRADE_URL }}
|
2024-07-19 05:15:57 +03:00
|
|
|
MIKRO_RENEW_URL: ${{ secrets.MIKRO_RENEW_URL }}
|
|
|
|
CUSTOM_RENEW_URL: ${{ secrets.CUSTOM_RENEW_URL }}
|
2024-06-15 02:18:14 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v5
|
|
|
|
with:
|
|
|
|
python-version: '3.11'
|
2024-06-16 00:04:10 +03:00
|
|
|
|
2024-07-14 10:37:23 +03:00
|
|
|
- name: Get latest routeros version
|
|
|
|
id: get_latest
|
2024-07-13 17:54:09 +03:00
|
|
|
run: |
|
|
|
|
echo $(uname -a)
|
2024-07-13 17:57:15 +03:00
|
|
|
LATEST_VERSION=$(wget -nv -O - https://${{ env.MIKRO_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
2024-07-13 17:54:09 +03:00
|
|
|
echo Latest Version:$LATEST_VERSION
|
|
|
|
if [ "${{ github.event_name }}" == "schedule" ]; then
|
2024-07-13 17:55:32 +03:00
|
|
|
_LATEST_VERSION=$(wget -nv -O - https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
|
2024-07-13 17:54:09 +03:00
|
|
|
if [ "$_LATEST_VERSION" == "$LATEST_VERSION" ]; then
|
|
|
|
echo "No new version found"
|
2024-07-14 10:48:28 +03:00
|
|
|
echo "has_new_version=false" >> $GITHUB_OUTPUT
|
2024-07-13 17:54:09 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
2024-07-14 10:48:28 +03:00
|
|
|
echo "has_new_version=true" >> $GITHUB_OUTPUT
|
2024-07-13 17:54:09 +03:00
|
|
|
BUILD_TIME=$(date +"%s")
|
|
|
|
echo Build Time:$BUILD_TIME
|
2024-07-13 17:57:15 +03:00
|
|
|
wget -nv -O CHANGELOG https://${{ env.MIKRO_UPGRADE_URL }}/routeros/$LATEST_VERSION/CHANGELOG
|
2024-07-13 17:54:09 +03:00
|
|
|
cat CHANGELOG
|
|
|
|
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
|
|
|
|
echo "BUILD_TIME=${BUILD_TIME}" >> $GITHUB_ENV
|
2024-07-19 05:15:57 +03:00
|
|
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
2024-07-13 17:54:09 +03:00
|
|
|
ARCH=''
|
|
|
|
echo "ARCH=$ARCH" >> $GITHUB_ENV
|
|
|
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
|
|
|
ARCH='-arm64'
|
|
|
|
echo "ARCH=$ARCH" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
|
2024-06-24 11:01:02 +03:00
|
|
|
- name: Cache Squashfs
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-06-24 11:01:02 +03:00
|
|
|
id: cache-squashfs
|
|
|
|
uses: actions/cache@v4
|
2024-06-16 00:04:10 +03:00
|
|
|
with:
|
2024-06-24 11:01:02 +03:00
|
|
|
path: |
|
|
|
|
python3.sfs
|
|
|
|
option.sfs
|
2024-07-12 01:09:52 +03:00
|
|
|
key: busybox-python3-squashfs-${{ matrix.arch }}
|
2024-06-24 11:01:02 +03:00
|
|
|
|
|
|
|
- name: Create Squashfs for option and python3
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-squashfs.outputs.cache-hit != 'true'
|
2024-06-24 11:01:02 +03:00
|
|
|
run: |
|
|
|
|
sudo mkdir -p ./option-root/bin/
|
2024-07-19 05:15:57 +03:00
|
|
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
|
|
|
sudo cp busybox/busybox_x86 ./option-root/bin/busybox
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo chmod +x ./option-root/bin/busybox
|
|
|
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
|
|
|
sudo cp busybox/busybox_aarch64 ./option-root/bin/busybox
|
|
|
|
sudo chmod +x ./option-root/bin/busybox
|
|
|
|
fi
|
2024-07-19 05:15:57 +03:00
|
|
|
sudo chmod +x ./busybox/busybox_x86
|
|
|
|
COMMANDS=$(./busybox/busybox_x86 --list)
|
2024-06-24 11:01:02 +03:00
|
|
|
for cmd in $COMMANDS; do
|
|
|
|
sudo ln -sf /pckg/option/bin/busybox ./option-root/bin/$cmd
|
|
|
|
done
|
|
|
|
sudo mksquashfs option-root option.sfs -quiet -comp xz -no-xattrs -b 256k
|
|
|
|
sudo rm -rf option-root
|
2024-07-19 05:15:57 +03:00
|
|
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
|
|
|
sudo wget -O cpython-3.11.9.tar.gz -nv https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240713-x86_64-unknown-linux-gnu-install_only.tar.gz
|
2024-07-12 01:09:52 +03:00
|
|
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
2024-07-19 05:15:57 +03:00
|
|
|
sudo wget -O cpython-3.11.9.tar.gz -nv https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240713-aarch64-unknown-linux-gnu-install_only.tar.gz
|
2024-07-12 01:09:52 +03:00
|
|
|
fi
|
2024-06-24 11:01:02 +03:00
|
|
|
sudo tar -xf cpython-3.11.9.tar.gz
|
|
|
|
sudo rm cpython-3.11.9.tar.gz
|
|
|
|
sudo rm -rf ./python/include
|
|
|
|
sudo rm -rf ./python/share
|
|
|
|
sudo mksquashfs python python3.sfs -quiet -comp xz -no-xattrs -b 256k
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo rm -rf ./python
|
2024-06-16 00:04:10 +03:00
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
- name: Cache NetInstall ${{ env.LATEST_VERSION }}
|
2024-07-19 05:15:57 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
2024-07-12 01:09:52 +03:00
|
|
|
id: cache-netinstall
|
2024-06-24 10:30:39 +03:00
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: |
|
2024-06-24 12:59:14 +03:00
|
|
|
netinstall.zip
|
2024-07-14 01:32:48 +03:00
|
|
|
netinstall.tar.gz
|
2024-07-12 01:09:52 +03:00
|
|
|
key: netinstall-${{ env.LATEST_VERSION }}
|
2024-06-24 10:30:39 +03:00
|
|
|
|
2024-07-14 01:32:48 +03:00
|
|
|
- name: Get netinstall ${{ env.LATEST_VERSION }}
|
2024-07-19 05:15:57 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-netinstall.outputs.cache-hit != 'true'
|
2024-06-15 02:18:14 +03:00
|
|
|
run: |
|
2024-06-24 12:59:14 +03:00
|
|
|
sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip
|
2024-07-14 01:32:48 +03:00
|
|
|
sudo wget -nv -O netinstall.tar.gz https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.tar.gz
|
2024-06-19 09:04:27 +03:00
|
|
|
|
2024-07-14 01:32:48 +03:00
|
|
|
- name: Patch netinstall ${{ env.LATEST_VERSION }}
|
2024-07-19 05:15:57 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
2024-06-18 08:17:48 +03:00
|
|
|
run: |
|
2024-06-24 12:59:14 +03:00
|
|
|
sudo unzip netinstall.zip
|
2024-06-18 08:20:22 +03:00
|
|
|
sudo -E python3 patch.py netinstall netinstall.exe
|
|
|
|
sudo zip netinstall-$LATEST_VERSION.zip ./netinstall.exe
|
2024-07-14 01:32:48 +03:00
|
|
|
sudo tar -xvf netinstall.tar.gz
|
|
|
|
sudo -E python3 patch.py netinstall netinstall-cli
|
|
|
|
sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli
|
2024-06-18 08:17:48 +03:00
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
- name: Cache mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-07-12 01:09:52 +03:00
|
|
|
id: cache-mikrotik
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
mikrotik.iso
|
|
|
|
key: mikrotik-${{ env.LATEST_VERSION }}-${{ matrix.arch }}
|
|
|
|
|
|
|
|
- name: Get mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-mikrotik.outputs.cache-hit != 'true'
|
2024-07-12 01:09:52 +03:00
|
|
|
run: |
|
|
|
|
sudo wget -nv -O mikrotik.iso https://download.mikrotik.com/routeros/$LATEST_VERSION/mikrotik-$LATEST_VERSION$ARCH.iso
|
|
|
|
|
2024-07-13 12:44:17 +03:00
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
- name: Patch mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-06-15 02:18:14 +03:00
|
|
|
run: |
|
2024-07-13 16:34:02 +03:00
|
|
|
sudo apt-get install -y mkisofs xorriso > /dev/null
|
2024-06-15 02:18:14 +03:00
|
|
|
sudo mkdir ./iso
|
2024-06-24 12:59:14 +03:00
|
|
|
sudo mount -o loop,ro mikrotik.iso ./iso
|
2024-06-15 02:18:14 +03:00
|
|
|
sudo mkdir ./new_iso
|
|
|
|
sudo cp -r ./iso/* ./new_iso/
|
|
|
|
sudo rsync -a ./iso/ ./new_iso/
|
|
|
|
sudo umount ./iso
|
|
|
|
sudo rm -rf ./iso
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo mv ./new_iso/routeros-$LATEST_VERSION$ARCH.npk ./
|
|
|
|
sudo -E python3 patch.py npk routeros-$LATEST_VERSION$ARCH.npk
|
2024-06-15 02:18:14 +03:00
|
|
|
NPK_FILES=$(find ./new_iso/*.npk)
|
|
|
|
for file in $NPK_FILES; do
|
|
|
|
sudo -E python3 npk.py sign $file $file
|
|
|
|
done
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo cp routeros-$LATEST_VERSION$ARCH.npk ./new_iso/
|
|
|
|
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./option-$LATEST_VERSION$ARCH.npk option ./option.sfs -desc="busybox"
|
|
|
|
sudo cp option-$LATEST_VERSION$ARCH.npk ./new_iso/
|
|
|
|
sudo -E python3 npk.py create ./new_iso/gps-$LATEST_VERSION$ARCH.npk ./python3-$LATEST_VERSION$ARCH.npk python3 ./python3.sfs -desc="python 3.11.9"
|
|
|
|
sudo cp python3-$LATEST_VERSION$ARCH.npk ./new_iso/
|
2024-06-24 06:06:02 +03:00
|
|
|
sudo mkdir ./efiboot
|
|
|
|
sudo mount -o loop ./new_iso/efiboot.img ./efiboot
|
2024-07-19 05:15:57 +03:00
|
|
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo -E python3 patch.py kernel ./efiboot/linux.x86_64
|
|
|
|
sudo cp ./efiboot/linux.x86_64 ./BOOTX64.EFI
|
|
|
|
sudo cp ./BOOTX64.EFI ./new_iso/isolinux/linux
|
|
|
|
sudo umount ./efiboot
|
|
|
|
sudo mkisofs -o mikrotik-$LATEST_VERSION$ARCH.iso \
|
|
|
|
-V "MikroTik $LATEST_VERSION ${{ matrix.arch }}" \
|
|
|
|
-sysid "" -preparer "MiKroTiK" \
|
|
|
|
-publisher "" -A "MiKroTiK RouterOS" \
|
2024-07-13 16:34:02 +03:00
|
|
|
-input-charset utf-8 \
|
2024-07-12 01:09:52 +03:00
|
|
|
-b isolinux/isolinux.bin \
|
|
|
|
-c isolinux/boot.cat \
|
|
|
|
-no-emul-boot \
|
|
|
|
-boot-load-size 4 \
|
|
|
|
-boot-info-table \
|
|
|
|
-eltorito-alt-boot \
|
|
|
|
-e efiboot.img \
|
|
|
|
-no-emul-boot \
|
|
|
|
-R -J \
|
|
|
|
./new_iso
|
|
|
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
|
|
|
sudo -E python3 patch.py kernel ./efiboot/EFI/BOOT/BOOTAA64.EFI
|
|
|
|
sudo umount ./efiboot
|
2024-07-13 16:34:02 +03:00
|
|
|
sudo xorriso -as mkisofs -o mikrotik-$LATEST_VERSION$ARCH.iso \
|
2024-07-12 01:09:52 +03:00
|
|
|
-V "MikroTik $LATEST_VERSION ${{ matrix.arch }}" \
|
|
|
|
-sysid "" -preparer "MiKroTiK" \
|
|
|
|
-publisher "" -A "MiKroTiK RouterOS" \
|
2024-07-13 16:34:02 +03:00
|
|
|
-input-charset utf-8 \
|
|
|
|
-b efiboot.img \
|
2024-07-12 01:09:52 +03:00
|
|
|
-no-emul-boot \
|
|
|
|
-R -J \
|
|
|
|
./new_iso
|
|
|
|
fi
|
2024-07-13 16:34:02 +03:00
|
|
|
sudo rm -rf ./efiboot
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo mkdir ./all_packages
|
|
|
|
sudo cp ./new_iso/*.npk ./all_packages/
|
|
|
|
sudo rm -rf ./new_iso
|
|
|
|
cd ./all_packages
|
2024-07-19 05:15:57 +03:00
|
|
|
sudo zip ../all_packages-${{ matrix.arch }}-$LATEST_VERSION.zip *.npk
|
2024-06-24 04:50:31 +03:00
|
|
|
cd ..
|
2024-06-15 02:18:14 +03:00
|
|
|
|
2024-06-24 12:59:14 +03:00
|
|
|
- name: Cache refind
|
2024-07-19 05:15:57 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
2024-06-24 12:59:14 +03:00
|
|
|
id: cache-refind
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: refind-bin-0.14.2.zip
|
|
|
|
key: refind
|
|
|
|
|
|
|
|
- name: Get refind
|
2024-07-19 05:15:57 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86' && steps.cache-refind.outputs.cache-hit != 'true'
|
2024-06-24 12:59:14 +03:00
|
|
|
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
|
2024-07-19 05:15:57 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86'
|
2024-06-24 12:59:14 +03:00
|
|
|
run: |
|
2024-06-24 13:02:50 +03:00
|
|
|
sudo modprobe nbd
|
2024-07-03 07:05:38 +03:00
|
|
|
sudo apt-get install -y qemu-utils extlinux > /dev/null
|
2024-07-03 06:43:18 +03:00
|
|
|
truncate --size 128M install-image-$LATEST_VERSION.img
|
2024-06-24 12:59:14 +03:00
|
|
|
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
|
2024-07-19 05:27:40 +03:00
|
|
|
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
|
2024-07-19 05:24:54 +03:00
|
|
|
sudo extlinux --install -H 64 -S 32 ./install/
|
2024-07-19 05:27:40 +03:00
|
|
|
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
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo cp ./BOOTX64.EFI ./install/linux
|
|
|
|
NPK_FILES=($(find ./all_packages/*.npk))
|
2024-06-24 12:59:14 +03:00
|
|
|
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
|
|
|
|
|
2024-07-13 12:44:17 +03:00
|
|
|
- name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'arm64'
|
2024-07-13 12:44:17 +03:00
|
|
|
id: cache-chr-img
|
|
|
|
uses: actions/cache@v4
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
chr.img
|
|
|
|
key: chr-${{ env.LATEST_VERSION }}-${{ matrix.arch }}.img
|
|
|
|
|
2024-07-13 12:45:15 +03:00
|
|
|
- name: Get chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-chr-img.outputs.cache-hit != 'true' && matrix.arch == 'arm64'
|
2024-07-13 12:44:17 +03:00
|
|
|
run: |
|
2024-07-13 12:51:35 +03:00
|
|
|
sudo wget -nv -O chr.img.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/chr-$LATEST_VERSION$ARCH.img.zip
|
|
|
|
sudo unzip chr.img.zip
|
|
|
|
sudo rm chr.img.zip
|
|
|
|
sudo mv chr-$LATEST_VERSION$ARCH.img chr.img
|
2024-07-13 12:44:17 +03:00
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
- name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-06-15 18:04:46 +03:00
|
|
|
run: |
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo modprobe nbd
|
|
|
|
sudo apt-get install -y qemu-utils extlinux > /dev/null
|
|
|
|
truncate --size 128M chr-$LATEST_VERSION$ARCH.img
|
2024-06-23 22:23:03 +03:00
|
|
|
sgdisk --clear --set-alignment=2 \
|
2024-07-03 08:05:28 +03:00
|
|
|
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
2024-06-23 22:07:59 +03:00
|
|
|
--new=2::-0 --typecode=2:8300 --change-name=2:"RouterOS" \
|
2024-06-23 22:37:10 +03:00
|
|
|
--gpttombr=1:2 \
|
2024-07-12 01:09:52 +03:00
|
|
|
chr-$LATEST_VERSION$ARCH.img
|
|
|
|
dd if=chr-$LATEST_VERSION$ARCH.img of=pt.bin bs=1 count=66 skip=446
|
2024-06-23 22:23:03 +03:00
|
|
|
echo -e "\x80" | dd of=pt.bin bs=1 count=1 conv=notrunc
|
|
|
|
sgdisk --mbrtogpt --clear --set-alignment=2 \
|
2024-07-03 08:05:28 +03:00
|
|
|
--new=1::+32M --typecode=1:8300 --change-name=1:"RouterOS Boot" --attributes=1:set:2 \
|
2024-06-23 22:07:59 +03:00
|
|
|
--new=2::-0 --typecode=2:8300 --change-name=2:"RouterOS" \
|
2024-07-12 01:09:52 +03:00
|
|
|
chr-$LATEST_VERSION$ARCH.img
|
|
|
|
dd if=mbr.bin of=chr-$LATEST_VERSION$ARCH.img bs=1 count=446 conv=notrunc
|
|
|
|
dd if=pt.bin of=chr-$LATEST_VERSION$ARCH.img bs=1 count=66 seek=446 conv=notrunc
|
|
|
|
sudo qemu-nbd -c /dev/nbd0 -f raw chr-$LATEST_VERSION$ARCH.img
|
2024-06-20 23:33:33 +03:00
|
|
|
sudo mkfs.vfat -n "Boot" /dev/nbd0p1
|
2024-06-23 22:23:03 +03:00
|
|
|
sudo mkfs.ext4 -F -L "RouterOS" -m 0 /dev/nbd0p2
|
2024-06-23 22:07:59 +03:00
|
|
|
sudo mkdir -p ./img/{boot,routeros}
|
|
|
|
sudo mount /dev/nbd0p1 ./img/boot/
|
2024-07-19 05:15:57 +03:00
|
|
|
if [ "${{ matrix.arch }}" == "x86" ]; then
|
2024-07-13 12:44:17 +03:00
|
|
|
sudo mkdir -p ./img/boot/{BOOT,EFI/BOOT}
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo cp BOOTX64.EFI ./img/boot/EFI/BOOT/BOOTX64.EFI
|
|
|
|
sudo ./extlinux --install -H 64 -S 32 ./img/boot/BOOT
|
|
|
|
echo -e "default system\nlabel system\n\tkernel /EFI/BOOT/BOOTX64.EFI\n\tappend load_ramdisk=1 root=/dev/ram0 quiet" > syslinux.cfg
|
|
|
|
sudo cp syslinux.cfg ./img/boot/BOOT/
|
|
|
|
sudo rm syslinux.cfg
|
2024-07-12 05:27:06 +03:00
|
|
|
elif [ "${{ matrix.arch }}" == "arm64" ]; then
|
2024-07-13 12:44:17 +03:00
|
|
|
sudo qemu-nbd -c /dev/nbd1 -f raw chr.img
|
|
|
|
sudo mkdir -p ./chr/boot
|
|
|
|
sudo mount /dev/nbd1p1 ./chr/boot/
|
2024-07-16 09:23:53 +03:00
|
|
|
sudo -E python3 patch.py kernel ./chr/boot/EFI/BOOT/BOOTAA64.EFI -O ./BOOTAA64.EFI
|
2024-07-13 12:51:35 +03:00
|
|
|
sudo mkdir -p ./img/boot/EFI/BOOT
|
2024-07-16 09:20:09 +03:00
|
|
|
sudo cp ./BOOTAA64.EFI ./img/boot/EFI/BOOT/BOOTAA64.EFI
|
2024-07-13 12:44:17 +03:00
|
|
|
sudo umount /dev/nbd1p1
|
|
|
|
sudo rm -rf ./chr
|
|
|
|
sudo qemu-nbd -d /dev/nbd1
|
2024-07-12 01:09:52 +03:00
|
|
|
fi
|
2024-06-20 23:38:19 +03:00
|
|
|
sudo umount /dev/nbd0p1
|
2024-06-23 22:07:59 +03:00
|
|
|
sudo mount /dev/nbd0p2 ./img/routeros/
|
2024-07-13 12:44:17 +03:00
|
|
|
sudo mkdir -p ./img/routeros/{var/pdb/{system,option},boot,rw}
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo cp ./all_packages/option-$LATEST_VERSION$ARCH.npk ./img/routeros/var/pdb/option/image
|
|
|
|
sudo cp ./all_packages/routeros-$LATEST_VERSION$ARCH.npk ./img/routeros/var/pdb/system/image
|
2024-06-20 23:10:02 +03:00
|
|
|
sudo umount /dev/nbd0p2
|
2024-06-23 22:07:59 +03:00
|
|
|
sudo rm -rf ./img
|
2024-06-18 18:43:01 +03:00
|
|
|
sudo qemu-nbd -d /dev/nbd0
|
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo qemu-img convert -f raw -O qcow2 chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.qcow2
|
|
|
|
sudo qemu-img convert -f raw -O vmdk chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vmdk
|
|
|
|
sudo qemu-img convert -f raw -O vpc chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vhd
|
|
|
|
sudo qemu-img convert -f raw -O vhdx chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vhdx
|
|
|
|
sudo qemu-img convert -f raw -O vdi chr-$LATEST_VERSION$ARCH.img chr-$LATEST_VERSION$ARCH.vdi
|
2024-06-20 08:47:39 +03:00
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
sudo zip chr-$LATEST_VERSION$ARCH.qcow2.zip chr-$LATEST_VERSION$ARCH.qcow2
|
|
|
|
sudo zip chr-$LATEST_VERSION$ARCH.vmdk.zip chr-$LATEST_VERSION$ARCH.vmdk
|
|
|
|
sudo zip chr-$LATEST_VERSION$ARCH.vhd.zip chr-$LATEST_VERSION$ARCH.vhd
|
|
|
|
sudo zip chr-$LATEST_VERSION$ARCH.vhdx.zip chr-$LATEST_VERSION$ARCH.vhdx
|
|
|
|
sudo zip chr-$LATEST_VERSION$ARCH.vdi.zip chr-$LATEST_VERSION$ARCH.vdi
|
|
|
|
sudo zip chr-$LATEST_VERSION$ARCH.img.zip chr-$LATEST_VERSION$ARCH.img
|
2024-06-20 08:47:39 +03:00
|
|
|
|
2024-07-13 16:37:46 +03:00
|
|
|
sudo rm chr-$LATEST_VERSION$ARCH.qcow2
|
|
|
|
sudo rm chr-$LATEST_VERSION$ARCH.vmdk
|
|
|
|
sudo rm chr-$LATEST_VERSION$ARCH.vhd
|
|
|
|
sudo rm chr-$LATEST_VERSION$ARCH.vhdx
|
|
|
|
sudo rm chr-$LATEST_VERSION$ARCH.vdi
|
|
|
|
sudo rm chr-$LATEST_VERSION$ARCH.img
|
2024-06-18 18:43:01 +03:00
|
|
|
|
2024-07-12 01:09:52 +03:00
|
|
|
# - name: Upload artifact
|
|
|
|
# uses: actions/upload-artifact@v4
|
|
|
|
# with:
|
|
|
|
# name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"
|
|
|
|
# path: |
|
|
|
|
# mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
|
|
|
# chr-${{ env.LATEST_VERSION }}*.zip
|
|
|
|
# netinstall-${{ env.LATEST_VERSION }}.zip
|
|
|
|
# install-image-${{ env.LATEST_VERSION }}.zip
|
|
|
|
# routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
|
|
|
# option-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
|
|
|
# all_packages-*-${{ env.LATEST_VERSION }}.zip
|
|
|
|
|
2024-07-01 07:04:53 +03:00
|
|
|
- name: Upload Files
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-06-30 23:25:55 +03:00
|
|
|
run: |
|
2024-07-01 17:42:31 +03:00
|
|
|
mkdir -p ./publish/$LATEST_VERSION
|
2024-07-03 07:08:13 +03:00
|
|
|
echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWESTa7.${{ matrix.channel }}
|
2024-07-02 05:12:24 +03:00
|
|
|
cp CHANGELOG ./publish/$LATEST_VERSION/
|
2024-07-12 01:09:52 +03:00
|
|
|
cp ./all_packages/*.npk ./publish/$LATEST_VERSION/
|
2024-07-01 17:50:34 +03:00
|
|
|
sudo apt-get install -y lftp > /dev/null 2>&1
|
2024-07-01 17:42:31 +03:00
|
|
|
sudo -E lftp -u ${{ secrets.SSH_USERNAME }},'${{ secrets.SSH_PASSWORD }}' sftp://${{ secrets.SSH_SERVER }}:${{ secrets.SSH_PORT }} <<EOF
|
2024-07-01 17:53:21 +03:00
|
|
|
set sftp:auto-confirm yes
|
2024-07-03 06:43:18 +03:00
|
|
|
mirror --reverse --verbose --only-newer ./publish ${{ secrets.SSH_DIRECTORY }}
|
2024-07-01 17:53:21 +03:00
|
|
|
bye
|
|
|
|
EOF
|
2024-06-24 10:42:25 +03:00
|
|
|
|
2024-07-12 01:16:44 +03:00
|
|
|
- name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-06-15 02:18:14 +03:00
|
|
|
run: |
|
|
|
|
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
2024-07-12 01:16:44 +03:00
|
|
|
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
|
2024-06-15 02:18:14 +03:00
|
|
|
RELEASE_ID=$(echo $RELEASE_INFO | jq -r '.id')
|
|
|
|
echo "Release ID: $RELEASE_ID"
|
|
|
|
if [ "$RELEASE_ID" != "null" ]; then
|
2024-07-12 01:16:44 +03:00
|
|
|
curl -X DELETE -H "$HEADER" https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$LATEST_VERSION$ARCH
|
|
|
|
echo "Tag $LATEST_VERSION$ARCH deleted successfully."
|
2024-06-15 02:18:14 +03:00
|
|
|
curl -X DELETE -H "$HEADER" https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID
|
2024-07-12 01:16:44 +03:00
|
|
|
echo "Release with tag $LATEST_VERSION$ARCH deleted successfully."
|
2024-06-15 02:18:14 +03:00
|
|
|
else
|
2024-06-18 08:17:48 +03:00
|
|
|
echo "Release not found for tag: $LATEST_VERSION)"
|
2024-06-15 02:18:14 +03:00
|
|
|
fi
|
|
|
|
|
2024-07-12 01:16:44 +03:00
|
|
|
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
|
2024-07-14 10:37:23 +03:00
|
|
|
if: steps.get_latest.outputs.has_new_version == 'true'
|
2024-06-15 02:18:14 +03:00
|
|
|
uses: softprops/action-gh-release@v2
|
|
|
|
with:
|
2024-07-12 01:17:57 +03:00
|
|
|
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"
|
2024-07-02 05:12:24 +03:00
|
|
|
body_path: "CHANGELOG"
|
2024-07-12 01:16:44 +03:00
|
|
|
tag_name: ${{ env.LATEST_VERSION }}${{ env.ARCH }}
|
2024-07-19 05:15:57 +03:00
|
|
|
make_latest: ${{ matrix.channel == 'stable'}} && ${{ matrix.arch == 'x86'}}
|
2024-06-19 04:07:18 +03:00
|
|
|
prerelease: ${{ matrix.channel == 'testing' }}
|
2024-06-18 11:56:11 +03:00
|
|
|
files: |
|
2024-07-12 01:09:52 +03:00
|
|
|
mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
|
2024-06-20 08:40:38 +03:00
|
|
|
chr-${{ env.LATEST_VERSION }}*.zip
|
2024-07-14 01:32:48 +03:00
|
|
|
netinstall-${{ env.LATEST_VERSION }}.*
|
2024-06-24 04:50:31 +03:00
|
|
|
install-image-${{ env.LATEST_VERSION }}.zip
|
2024-07-12 01:09:52 +03:00
|
|
|
routeros-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
|
|
|
option-${{ env.LATEST_VERSION }}${{ env.ARCH }}.npk
|
2024-07-16 09:20:09 +03:00
|
|
|
all_packages-*-${{ env.LATEST_VERSION }}.zip
|
|
|
|
*.EFI
|