modified: .github/workflows/mikrotik_patch.yml

This commit is contained in:
zyb 2024-07-14 15:37:23 +08:00
parent 2fe3072ecf
commit 523b98a09b

View File

@ -40,7 +40,8 @@ jobs:
with: with:
python-version: '3.11' python-version: '3.11'
- name: Get latest routeros version - name: Get latest routeros version
id: get_latest
run: | run: |
echo $(uname -a) echo $(uname -a)
LATEST_VERSION=$(wget -nv -O - https://${{ env.MIKRO_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1) LATEST_VERSION=$(wget -nv -O - https://${{ env.MIKRO_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
@ -49,9 +50,11 @@ jobs:
_LATEST_VERSION=$(wget -nv -O - https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1) _LATEST_VERSION=$(wget -nv -O - https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/NEWESTa7.${{ matrix.channel }} | cut -d ' ' -f1)
if [ "$_LATEST_VERSION" == "$LATEST_VERSION" ]; then if [ "$_LATEST_VERSION" == "$LATEST_VERSION" ]; then
echo "No new version found" echo "No new version found"
echo "::set-output name=has_new_version::false"
exit 0 exit 0
fi fi
fi fi
echo "::set-output name=has_new_version::true"
BUILD_TIME=$(date +"%s") BUILD_TIME=$(date +"%s")
echo Build Time:$BUILD_TIME echo Build Time:$BUILD_TIME
wget -nv -O CHANGELOG https://${{ env.MIKRO_UPGRADE_URL }}/routeros/$LATEST_VERSION/CHANGELOG wget -nv -O CHANGELOG https://${{ env.MIKRO_UPGRADE_URL }}/routeros/$LATEST_VERSION/CHANGELOG
@ -67,6 +70,7 @@ jobs:
fi fi
- name: Cache Squashfs - name: Cache Squashfs
if: steps.get_latest.outputs.has_new_version == 'true'
id: cache-squashfs id: cache-squashfs
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -76,7 +80,7 @@ jobs:
key: busybox-python3-squashfs-${{ matrix.arch }} key: busybox-python3-squashfs-${{ matrix.arch }}
- name: Create Squashfs for option and python3 - name: Create Squashfs for option and python3
if: steps.cache-squashfs.outputs.cache-hit != 'true' if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-squashfs.outputs.cache-hit != 'true'
run: | run: |
sudo mkdir -p ./option-root/bin/ sudo mkdir -p ./option-root/bin/
if [ "${{ matrix.arch }}" == "x86_64" ]; then if [ "${{ matrix.arch }}" == "x86_64" ]; then
@ -106,7 +110,7 @@ jobs:
sudo rm -rf ./python sudo rm -rf ./python
- name: Cache NetInstall ${{ env.LATEST_VERSION }} - name: Cache NetInstall ${{ env.LATEST_VERSION }}
if: matrix.arch == 'x86_64' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64'
id: cache-netinstall id: cache-netinstall
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -116,13 +120,13 @@ jobs:
key: netinstall-${{ env.LATEST_VERSION }} key: netinstall-${{ env.LATEST_VERSION }}
- name: Get netinstall ${{ env.LATEST_VERSION }} - name: Get netinstall ${{ env.LATEST_VERSION }}
if: matrix.arch == 'x86_64' && steps.cache-netinstall.outputs.cache-hit != 'true' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64' && steps.cache-netinstall.outputs.cache-hit != 'true'
run: | run: |
sudo wget -nv -O netinstall.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/netinstall-$LATEST_VERSION.zip 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 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 }} - name: Patch netinstall ${{ env.LATEST_VERSION }}
if: matrix.arch == 'x86_64' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64'
run: | run: |
sudo unzip netinstall.zip sudo unzip netinstall.zip
sudo -E python3 patch.py netinstall netinstall.exe sudo -E python3 patch.py netinstall netinstall.exe
@ -132,6 +136,7 @@ jobs:
sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli
- name: Cache mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso - name: Cache mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
if: steps.get_latest.outputs.has_new_version == 'true'
id: cache-mikrotik id: cache-mikrotik
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -140,12 +145,13 @@ jobs:
key: mikrotik-${{ env.LATEST_VERSION }}-${{ matrix.arch }} key: mikrotik-${{ env.LATEST_VERSION }}-${{ matrix.arch }}
- name: Get mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso - name: Get mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
if: steps.cache-mikrotik.outputs.cache-hit != 'true' if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-mikrotik.outputs.cache-hit != 'true'
run: | run: |
sudo wget -nv -O mikrotik.iso https://download.mikrotik.com/routeros/$LATEST_VERSION/mikrotik-$LATEST_VERSION$ARCH.iso sudo wget -nv -O mikrotik.iso https://download.mikrotik.com/routeros/$LATEST_VERSION/mikrotik-$LATEST_VERSION$ARCH.iso
- name: Patch mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso - name: Patch mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso
if: steps.get_latest.outputs.has_new_version == 'true'
run: | run: |
sudo apt-get install -y mkisofs xorriso > /dev/null sudo apt-get install -y mkisofs xorriso > /dev/null
sudo mkdir ./iso sudo mkdir ./iso
@ -214,7 +220,7 @@ jobs:
cd .. cd ..
- name: Cache refind - name: Cache refind
if: matrix.arch == 'x86_64' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64'
id: cache-refind id: cache-refind
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -222,11 +228,11 @@ jobs:
key: refind key: refind
- name: Get refind - name: Get refind
if: matrix.arch == 'x86_64' && steps.cache-refind.outputs.cache-hit != 'true' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64' && 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 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 - name: Create install-image-${{ env.LATEST_VERSION }}.img
if: matrix.arch == 'x86_64' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64'
run: | run: |
sudo modprobe nbd sudo modprobe nbd
sudo apt-get install -y qemu-utils extlinux > /dev/null sudo apt-get install -y qemu-utils extlinux > /dev/null
@ -275,7 +281,7 @@ jobs:
sudo rm ./install-image-$LATEST_VERSION.img sudo rm ./install-image-$LATEST_VERSION.img
- name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip - name: Cache chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img.zip
if: matrix.arch == 'arm64' if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'arm64'
id: cache-chr-img id: cache-chr-img
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -284,7 +290,7 @@ jobs:
key: chr-${{ env.LATEST_VERSION }}-${{ matrix.arch }}.img key: chr-${{ env.LATEST_VERSION }}-${{ matrix.arch }}.img
- name: Get chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img - name: Get chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
if: steps.cache-chr-img.outputs.cache-hit != 'true' && matrix.arch == 'arm64' if: steps.get_latest.outputs.has_new_version == 'true' && steps.cache-chr-img.outputs.cache-hit != 'true' && matrix.arch == 'arm64'
run: | run: |
sudo wget -nv -O chr.img.zip https://download.mikrotik.com/routeros/$LATEST_VERSION/chr-$LATEST_VERSION$ARCH.img.zip 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 unzip chr.img.zip
@ -292,6 +298,7 @@ jobs:
sudo mv chr-$LATEST_VERSION$ARCH.img chr.img sudo mv chr-$LATEST_VERSION$ARCH.img chr.img
- name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img - name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img
if: steps.get_latest.outputs.has_new_version == 'true'
run: | run: |
sudo modprobe nbd sudo modprobe nbd
sudo apt-get install -y qemu-utils extlinux > /dev/null sudo apt-get install -y qemu-utils extlinux > /dev/null
@ -375,6 +382,7 @@ jobs:
# all_packages-*-${{ env.LATEST_VERSION }}.zip # all_packages-*-${{ env.LATEST_VERSION }}.zip
- name: Upload Files - name: Upload Files
if: steps.get_latest.outputs.has_new_version == 'true'
run: | run: |
mkdir -p ./publish/$LATEST_VERSION mkdir -p ./publish/$LATEST_VERSION
echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWESTa7.${{ matrix.channel }} echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWESTa7.${{ matrix.channel }}
@ -388,6 +396,7 @@ jobs:
EOF EOF
- name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }} - name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
if: steps.get_latest.outputs.has_new_version == 'true'
run: | run: |
HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}" HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH) RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH)
@ -403,6 +412,7 @@ jobs:
fi fi
- name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }} - name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }}
if: steps.get_latest.outputs.has_new_version == 'true'
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}" name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"