From 3572a73c283f9c3d28e698cd75e6478ffa806ab2 Mon Sep 17 00:00:00 2001 From: elseif Date: Wed, 2 Sep 2026 10:55:18 +0800 Subject: [PATCH] modified: .github/workflows/build_docker.yml modified: .github/workflows/main.yml modified: .github/workflows/patch_v7.yml modified: chr.sh modified: setup-routeros.sh --- .github/workflows/build_docker.yml | 4 ++ .github/workflows/main.yml | 20 ------- .github/workflows/patch_v7.yml | 94 +++++++++++++++++++++++++----- chr.sh | 22 +++---- setup-routeros.sh | 15 ++--- 5 files changed, 98 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index f062ff7..4166f52 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -1,5 +1,9 @@ name: Build CHR Docker + on: + schedule: + - cron: "00 10 * * *" # At UTC 09:00 (Beijing 17:00) on every day + workflow_dispatch: inputs: version: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d316248..da7a4aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,26 +34,6 @@ jobs: channel: long-term release: true secrets: inherit - - # Patch_Testing_V7: - # if: | - # (github.event_name == 'schedule') || - # (github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v7')) - # uses: ./.github/workflows/patch_v7.yml - # with: - # channel: testing - # release: true - # secrets: inherit - - # Patch_Development_V7: - # if: | - # (github.event_name == 'schedule') || - # (github.event_name == 'workflow_dispatch' && (github.event.inputs.version == 'all' || github.event.inputs.version == 'v7')) - # uses: ./.github/workflows/patch_v7.yml - # with: - # channel: development - # release: true - # secrets: inherit Patch_Stable_V6: if: | diff --git a/.github/workflows/patch_v7.yml b/.github/workflows/patch_v7.yml index b3a8192..3ff1256 100644 --- a/.github/workflows/patch_v7.yml +++ b/.github/workflows/patch_v7.yml @@ -3,15 +3,13 @@ on: workflow_dispatch: inputs: channel: - description: 'Channel (stable, long-term, testing, development)' + description: 'Channel (stable, long-term)' required: true default: 'stable' type: choice options: - stable - long-term - # - testing - # - development arch: description: 'Architecture (x86, arm64)' required: true @@ -22,7 +20,7 @@ on: - x86 - arm64 version: - description: "Specify version (e.g., 7.19.2), empty for latest" + description: "Specify version (e.g., 7.xx.x), empty for latest" required: false default: '' type: string @@ -185,10 +183,8 @@ jobs: run: | echo "Creating Option Package Squashfs for channel: $CHANNEL, arch: $ARCH" mkdir -p $BUILD_DIR/option-root/bin/ - cp ./busybox/busybox_$ARCH $BUILD_DIR/option-root/bin/busybox - chmod +x $BUILD_DIR/option-root/bin/busybox - cp ./keygen/keygen_$ARCH $BUILD_DIR/option-root/bin/keygen - chmod +x $BUILD_DIR/option-root/bin/keygen + install -m 755 ./busybox/busybox_$ARCH $BUILD_DIR/option-root/bin/busybox + install -m 755 ./keygen/keygen_$ARCH $BUILD_DIR/option-root/bin/keygen chmod +x ./busybox/busybox_x86 COMMANDS=$(./busybox/busybox_x86 --list) for cmd in $COMMANDS; do @@ -415,10 +411,8 @@ jobs: ::shutdown:/sbin/openrc shutdown EOF - cp ./setup-routeros.sh $ROOTFS_DIR/usr/local/bin/setup-routeros - chmod +x $ROOTFS_DIR//usr/local/bin/setup-routeros - cp ./npkextract/npkextract $ROOTFS_DIR/usr/local/bin/npkextract - chmod +x $ROOTFS_DIR/usr/local/bin/npkextract + install -m 755 ./setup-routeros.sh $ROOTFS_DIR/usr/local/bin/setup-routeros + install -m 755 ./npkextract/npkextract $ROOTFS_DIR/usr/local/bin/npkextract cat << 'EOF' > $ROOTFS_DIR/root/.zprofile if command -v setup-routeros >/dev/null 2>&1; then @@ -644,7 +638,7 @@ jobs: -input-charset utf-8 \ -iso-level 3 \ $BUILD_DIR/new_iso - echo "✅ ISO created: " + echo "✅ arm64 ISO created: " ls -la $PUBLISH_DIR/mikrotik-$VERSION$ARCH_EXT.iso fi rm -rf $BUILD_DIR/new_iso @@ -931,6 +925,77 @@ jobs: echo "Release not found for tag: $VERSION$ARCH_EXT)" fi + - name: Generate Release Body + if: needs.Prepare_Patch.outputs.RELEASE == 'true' + run: | + RELEASE_BODY="$BUILD_DIR/RELEASE_BODY.md" + BASE_URL="https://github.com/${{ github.repository }}/releases/download/$VERSION$ARCH_EXT" + cat > "$RELEASE_BODY" << EOF + # RouterOS ${{ env.VERSION }}${{ env.ARCH_EXT }} Release + + **Build Time**: $BUILD_TIME + **Architecture**: $ARCH + **Channel**: $CHANNEL + +
RouterOS + + | Type | File | + |------|------| + EOF + + link_file() { + local file="$1" + if [ -f "$file" ]; then + local basename=$(basename "$file") + echo "[$basename]($BASE_URL/$basename)" + else + echo "N/A" + fi + } + + echo "| Main package | $(link_file "$PUBLISH_DIR/routeros-${VERSION}${ARCH_EXT}.npk") |" >> "$RELEASE_BODY" + echo "| Extra packages | $(link_file "$PUBLISH_DIR/all_packages-$ARCH-$VERSION.zip") |" >> "$RELEASE_BODY" + echo "| ISO Image | $(link_file "$PUBLISH_DIR/mikrotik-${VERSION}${ARCH_EXT}.iso") |" >> "$RELEASE_BODY" + if [ "$ARCH" == "x86" ]; then + echo "| Install Image | $(link_file "$PUBLISH_DIR/install-image-$VERSION.zip") |" >> "$RELEASE_BODY" + echo "| Netinstall | $(link_file "$PUBLISH_DIR/netinstall-$VERSION.zip") |" >> "$RELEASE_BODY" + fi + echo "
" >> "$RELEASE_BODY" + echo "" >> "$RELEASE_BODY" + + echo "
Cloud Hosted Router (CHR)" >> "$RELEASE_BODY" + echo "" >> "$RELEASE_BODY" + + if [ "$ARCH" == "x86" ]; then + echo "| Format | UEFI | Legacy BIOS |" >> "$RELEASE_BODY" + echo "|--------|------|-------------|" >> "$RELEASE_BODY" + else + echo "| Format | UEFI |" >> "$RELEASE_BODY" + echo "|--------|------|" >> "$RELEASE_BODY" + fi + + formats=("img" "ova" "qcow2" "vdi" "vhd" "vhdx" "vmdk") + for fmt in "${formats[@]}"; do + uefi_link=$(link_file "$PUBLISH_DIR/chr-$VERSION$ARCH_EXT.$fmt.zip") + if [ "$ARCH" == "x86" ]; then + legacy_link=$(link_file "$PUBLISH_DIR/chr-$VERSION$ARCH_EXT-legacy-bios.$fmt.zip") + echo "| $fmt | $uefi_link | $legacy_link |" >> "$RELEASE_BODY" + else + echo "| $fmt | $uefi_link |" >> "$RELEASE_BODY" + fi + done + echo "
" >> "$RELEASE_BODY" + echo "" >> "$RELEASE_BODY" + + + echo "
Changelog" >> "$RELEASE_BODY" + echo "" >> "$RELEASE_BODY" + echo "
" >> "$RELEASE_BODY"
+        cat "$PUBLISH_DIR/CHANGELOG" >> "$RELEASE_BODY"
+        echo "
" >> "$RELEASE_BODY" + echo "
" >> "$RELEASE_BODY" + echo "✅ Release body generated at $RELEASE_BODY" + - name: Create Release tag ${{ env.VERSION }}${{ env.ARCH_EXT }} if: needs.Prepare_Patch.outputs.RELEASE == 'true' uses: softprops/action-gh-release@v3 @@ -938,10 +1003,9 @@ jobs: name: "RouterOS ${{ env.VERSION }}${{ env.ARCH_EXT }}" repository: ${{ github.repository }} token: ${{ secrets.GITHUB_TOKEN }} - body_path: ${{env.PUBLISH_DIR}}/CHANGELOG + body_path: ${{env.BUILD_DIR}}/RELEASE_BODY.md tag_name: ${{ env.VERSION }}${{ env.ARCH_EXT }} make_latest: ${{ env.CHANNEL == 'stable' && matrix.arch == 'x86'}} - prerelease: ${{ env.CHANNEL == 'testing'}} files: | ${{env.PUBLISH_DIR}}/*.zip ${{env.PUBLISH_DIR}}/*.iso diff --git a/chr.sh b/chr.sh index 8d481be..9ff18ed 100644 --- a/chr.sh +++ b/chr.sh @@ -61,9 +61,9 @@ select_language() { MSG_GATEWAY="Gateway:" MSG_DNS="Domain Name Server:" MSG_SELECT_VERSION="Select the version you want to install:" + MSG_LTS="long-term (v7)" MSG_STABLE="stable (v7)" - MSG_TEST="testing (v7)" - MSG_LTS="long-term (v6)" + MSG_LTS6="long-term (v6)" MSG_STABLE6="stable (v6)" MSG_PLEASE_CHOOSE="Please choose an option:" MSG_UNSUPPORTED_ARCH="Error: Unsupported architecture: " @@ -92,9 +92,9 @@ select_language() { MSG_GATEWAY="网关地址:" MSG_DNS="DNS服务器:" MSG_SELECT_VERSION="请选择您要安装的版本:" + MSG_LTS="长期支持版 (v7)" MSG_STABLE="稳定版 (v7)" - MSG_TEST="测试版 (v7)" - MSG_LTS="长期支持版 (v6)" + MSG_LTS6="长期支持版 (v6)" MSG_STABLE6="稳定版 (v6)" MSG_PLEASE_CHOOSE="请选择一个选项:" MSG_UNSUPPORTED_ARCH="错误: 不支持的架构: " @@ -207,15 +207,15 @@ select_version() { x86_64|i386|i486|i586|i686) echo "$MSG_SELECT_VERSION" echo "1. $MSG_STABLE" - echo "2. $MSG_TEST" - echo "3. $MSG_LTS" - echo "4. $MSG_STABLE6" + echo "2. $MSG_LTS" + echo "3. $MSG_STABLE6" + echo "4. $MSG_LTS6" read -p "$MSG_PLEASE_CHOOSE [1-4]" version_choice ;; aarch64) echo "$MSG_SELECT_VERSION" echo "1. $MSG_STABLE" - echo "2. $MSG_TEST" + echo "2. $MSG_LTS" read -p "$MSG_PLEASE_CHOOSE [1-2]" version_choice ;; *) @@ -229,7 +229,7 @@ select_version() { V7=1 ;; 2) - VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.testing" | cut -d' ' -f1) + VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.long-term" | cut -d' ' -f1) V7=1 ;; 3) @@ -237,7 +237,7 @@ select_version() { echo "$MSG_ARM64_NOT_SUPPORT_V6" continue fi - VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.long-term" | cut -d' ' -f1) + VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.stable" | cut -d' ' -f1) V7=0 ;; 4) @@ -245,7 +245,7 @@ select_version() { echo "$MSG_ARM64_NOT_SUPPORT_V6" continue fi - VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.stable" | cut -d' ' -f1) + VERSION=$(http_get "https://upgrade.mikrotik.ltd/routeros/NEWEST6.long-term" | cut -d' ' -f1) V7=0 ;; *) diff --git a/setup-routeros.sh b/setup-routeros.sh index 5dc620e..880df80 100644 --- a/setup-routeros.sh +++ b/setup-routeros.sh @@ -779,13 +779,6 @@ step_install() { return 1 fi - # Must be 0x83, otherwise "ERROR: could not find disk!" - printf '\x83' | dd of="$TARGET_DISK" bs=1 seek=450 conv=notrunc >> "$LOG_FILE" 2>&1 || { - step_msg "[ 33%] [ERR] Step 3/8: Failed to change partition type on $TARGET_DISK" - echo "dd failed to change partition type on $TARGET_DISK" > "$ERR_FILE" - return 1 - } - # Active boot partition printf '\x80' | dd of="$TARGET_DISK" bs=1 seek=446 conv=notrunc >> "$LOG_FILE" 2>&1 || { step_msg "[ 33%] [ERR] Step 3/8: Failed to Active boot partition on $TARGET_DISK" @@ -793,10 +786,10 @@ step_install() { return 1 } - # Clear the 3rd partition entry generated by sgdisk --hybrid - dd if=/dev/zero of="$TARGET_DISK" bs=1 seek=478 count=16 conv=notrunc >> "$LOG_FILE" 2>&1 || { - step_msg "[ 33%] [ERR] Failed to clear 3rd MBR partition entry on $TARGET_DISK" - echo "dd failed to clear 3rd MBR partition entry on $TARGET_DISK" > "$ERR_FILE" + # Must be 0x83, otherwise "ERROR: could not find disk!" + printf '\x83' | dd of="$TARGET_DISK" bs=1 seek=450 conv=notrunc >> "$LOG_FILE" 2>&1 || { + step_msg "[ 33%] [ERR] Step 3/8: Failed to change partition type on $TARGET_DISK" + echo "dd failed to change partition type on $TARGET_DISK" > "$ERR_FILE" return 1 }