From 523b98a09bdfdd2415d638589b70177214fed035 Mon Sep 17 00:00:00 2001 From: zyb Date: Sun, 14 Jul 2024 15:37:23 +0800 Subject: [PATCH] modified: .github/workflows/mikrotik_patch.yml --- .github/workflows/mikrotik_patch.yml | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mikrotik_patch.yml b/.github/workflows/mikrotik_patch.yml index 9af3360..f33c440 100644 --- a/.github/workflows/mikrotik_patch.yml +++ b/.github/workflows/mikrotik_patch.yml @@ -40,7 +40,8 @@ jobs: with: python-version: '3.11' - - name: Get latest routeros version + - name: Get latest routeros version + id: get_latest run: | echo $(uname -a) 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) if [ "$_LATEST_VERSION" == "$LATEST_VERSION" ]; then echo "No new version found" + echo "::set-output name=has_new_version::false" exit 0 fi fi + echo "::set-output name=has_new_version::true" BUILD_TIME=$(date +"%s") echo Build Time:$BUILD_TIME wget -nv -O CHANGELOG https://${{ env.MIKRO_UPGRADE_URL }}/routeros/$LATEST_VERSION/CHANGELOG @@ -67,6 +70,7 @@ jobs: fi - name: Cache Squashfs + if: steps.get_latest.outputs.has_new_version == 'true' id: cache-squashfs uses: actions/cache@v4 with: @@ -76,7 +80,7 @@ jobs: key: busybox-python3-squashfs-${{ matrix.arch }} - 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: | sudo mkdir -p ./option-root/bin/ if [ "${{ matrix.arch }}" == "x86_64" ]; then @@ -106,7 +110,7 @@ jobs: sudo rm -rf ./python - 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 uses: actions/cache@v4 with: @@ -116,13 +120,13 @@ jobs: key: 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: | 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: matrix.arch == 'x86_64' + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64' run: | sudo unzip netinstall.zip sudo -E python3 patch.py netinstall netinstall.exe @@ -132,6 +136,7 @@ jobs: sudo tar -czvf netinstall-$LATEST_VERSION.tar.gz ./netinstall-cli - name: Cache mikrotik-${{ env.LATEST_VERSION }}${{ env.ARCH }}.iso + if: steps.get_latest.outputs.has_new_version == 'true' id: cache-mikrotik uses: actions/cache@v4 with: @@ -140,12 +145,13 @@ jobs: key: mikrotik-${{ env.LATEST_VERSION }}-${{ matrix.arch }} - 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: | 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 + if: steps.get_latest.outputs.has_new_version == 'true' run: | sudo apt-get install -y mkisofs xorriso > /dev/null sudo mkdir ./iso @@ -214,7 +220,7 @@ jobs: cd .. - name: Cache refind - if: matrix.arch == 'x86_64' + if: steps.get_latest.outputs.has_new_version == 'true' && matrix.arch == 'x86_64' id: cache-refind uses: actions/cache@v4 with: @@ -222,11 +228,11 @@ jobs: key: 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 - 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: | sudo modprobe nbd sudo apt-get install -y qemu-utils extlinux > /dev/null @@ -275,7 +281,7 @@ jobs: sudo rm ./install-image-$LATEST_VERSION.img - 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 uses: actions/cache@v4 with: @@ -284,7 +290,7 @@ jobs: key: chr-${{ env.LATEST_VERSION }}-${{ matrix.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: | 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 @@ -292,6 +298,7 @@ jobs: sudo mv chr-$LATEST_VERSION$ARCH.img chr.img - name: Create chr-${{ env.LATEST_VERSION }}${{ env.ARCH }}.img + if: steps.get_latest.outputs.has_new_version == 'true' run: | sudo modprobe nbd sudo apt-get install -y qemu-utils extlinux > /dev/null @@ -375,6 +382,7 @@ jobs: # all_packages-*-${{ env.LATEST_VERSION }}.zip - name: Upload Files + if: steps.get_latest.outputs.has_new_version == 'true' run: | mkdir -p ./publish/$LATEST_VERSION echo $LATEST_VERSION $BUILD_TIME > ./publish/NEWESTa7.${{ matrix.channel }} @@ -388,6 +396,7 @@ jobs: EOF - name: Delete Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }} + if: steps.get_latest.outputs.has_new_version == 'true' run: | HEADER="Authorization: token ${{ secrets.GITHUB_TOKEN }}" RELEASE_INFO=$(curl -s -H $HEADER https://api.github.com/repos/${{ github.repository }}/releases/tags/$LATEST_VERSION$ARCH) @@ -403,6 +412,7 @@ jobs: fi - name: Create Release tag ${{ env.LATEST_VERSION }} ${{ matrix.arch }} + if: steps.get_latest.outputs.has_new_version == 'true' uses: softprops/action-gh-release@v2 with: name: "RouterOS ${{ env.LATEST_VERSION }} ${{ matrix.arch }}"