modified: .github/workflows/build_docker.yml

modified:   .github/workflows/main.yml
	modified:   .github/workflows/patch_v7.yml
	modified:   chr.sh
	modified:   setup-routeros.sh
This commit is contained in:
elseif
2026-09-02 10:55:18 +08:00
parent 640fb1cd62
commit 3572a73c28
5 changed files with 98 additions and 57 deletions

View File

@@ -1,5 +1,9 @@
name: Build CHR Docker name: Build CHR Docker
on: on:
schedule:
- cron: "00 10 * * *" # At UTC 09:00 (Beijing 17:00) on every day
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:

View File

@@ -35,26 +35,6 @@ jobs:
release: true release: true
secrets: inherit 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: Patch_Stable_V6:
if: | if: |
(github.event_name == 'schedule') || (github.event_name == 'schedule') ||

View File

@@ -3,15 +3,13 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
channel: channel:
description: 'Channel (stable, long-term, testing, development)' description: 'Channel (stable, long-term)'
required: true required: true
default: 'stable' default: 'stable'
type: choice type: choice
options: options:
- stable - stable
- long-term - long-term
# - testing
# - development
arch: arch:
description: 'Architecture (x86, arm64)' description: 'Architecture (x86, arm64)'
required: true required: true
@@ -22,7 +20,7 @@ on:
- x86 - x86
- arm64 - arm64
version: 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 required: false
default: '' default: ''
type: string type: string
@@ -185,10 +183,8 @@ jobs:
run: | run: |
echo "Creating Option Package Squashfs for channel: $CHANNEL, arch: $ARCH" echo "Creating Option Package Squashfs for channel: $CHANNEL, arch: $ARCH"
mkdir -p $BUILD_DIR/option-root/bin/ mkdir -p $BUILD_DIR/option-root/bin/
cp ./busybox/busybox_$ARCH $BUILD_DIR/option-root/bin/busybox install -m 755 ./busybox/busybox_$ARCH $BUILD_DIR/option-root/bin/busybox
chmod +x $BUILD_DIR/option-root/bin/busybox install -m 755 ./keygen/keygen_$ARCH $BUILD_DIR/option-root/bin/keygen
cp ./keygen/keygen_$ARCH $BUILD_DIR/option-root/bin/keygen
chmod +x $BUILD_DIR/option-root/bin/keygen
chmod +x ./busybox/busybox_x86 chmod +x ./busybox/busybox_x86
COMMANDS=$(./busybox/busybox_x86 --list) COMMANDS=$(./busybox/busybox_x86 --list)
for cmd in $COMMANDS; do for cmd in $COMMANDS; do
@@ -415,10 +411,8 @@ jobs:
::shutdown:/sbin/openrc shutdown ::shutdown:/sbin/openrc shutdown
EOF EOF
cp ./setup-routeros.sh $ROOTFS_DIR/usr/local/bin/setup-routeros install -m 755 ./setup-routeros.sh $ROOTFS_DIR/usr/local/bin/setup-routeros
chmod +x $ROOTFS_DIR//usr/local/bin/setup-routeros install -m 755 ./npkextract/npkextract $ROOTFS_DIR/usr/local/bin/npkextract
cp ./npkextract/npkextract $ROOTFS_DIR/usr/local/bin/npkextract
chmod +x $ROOTFS_DIR/usr/local/bin/npkextract
cat << 'EOF' > $ROOTFS_DIR/root/.zprofile cat << 'EOF' > $ROOTFS_DIR/root/.zprofile
if command -v setup-routeros >/dev/null 2>&1; then if command -v setup-routeros >/dev/null 2>&1; then
@@ -644,7 +638,7 @@ jobs:
-input-charset utf-8 \ -input-charset utf-8 \
-iso-level 3 \ -iso-level 3 \
$BUILD_DIR/new_iso $BUILD_DIR/new_iso
echo "✅ ISO created: " echo "✅ arm64 ISO created: "
ls -la $PUBLISH_DIR/mikrotik-$VERSION$ARCH_EXT.iso ls -la $PUBLISH_DIR/mikrotik-$VERSION$ARCH_EXT.iso
fi fi
rm -rf $BUILD_DIR/new_iso rm -rf $BUILD_DIR/new_iso
@@ -931,6 +925,77 @@ jobs:
echo "Release not found for tag: $VERSION$ARCH_EXT)" echo "Release not found for tag: $VERSION$ARCH_EXT)"
fi 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
<details><summary><strong>RouterOS</strong></summary>
| 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 "</details>" >> "$RELEASE_BODY"
echo "" >> "$RELEASE_BODY"
echo "<details><summary><strong>Cloud Hosted Router (CHR)</strong></summary>" >> "$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 "</details>" >> "$RELEASE_BODY"
echo "" >> "$RELEASE_BODY"
echo "<details><summary><strong>Changelog</strong></summary>" >> "$RELEASE_BODY"
echo "" >> "$RELEASE_BODY"
echo "<pre>" >> "$RELEASE_BODY"
cat "$PUBLISH_DIR/CHANGELOG" >> "$RELEASE_BODY"
echo "</pre>" >> "$RELEASE_BODY"
echo "</details>" >> "$RELEASE_BODY"
echo "✅ Release body generated at $RELEASE_BODY"
- name: Create Release tag ${{ env.VERSION }}${{ env.ARCH_EXT }} - name: Create Release tag ${{ env.VERSION }}${{ env.ARCH_EXT }}
if: needs.Prepare_Patch.outputs.RELEASE == 'true' if: needs.Prepare_Patch.outputs.RELEASE == 'true'
uses: softprops/action-gh-release@v3 uses: softprops/action-gh-release@v3
@@ -938,10 +1003,9 @@ jobs:
name: "RouterOS ${{ env.VERSION }}${{ env.ARCH_EXT }}" name: "RouterOS ${{ env.VERSION }}${{ env.ARCH_EXT }}"
repository: ${{ github.repository }} repository: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }} 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 }} tag_name: ${{ env.VERSION }}${{ env.ARCH_EXT }}
make_latest: ${{ env.CHANNEL == 'stable' && matrix.arch == 'x86'}} make_latest: ${{ env.CHANNEL == 'stable' && matrix.arch == 'x86'}}
prerelease: ${{ env.CHANNEL == 'testing'}}
files: | files: |
${{env.PUBLISH_DIR}}/*.zip ${{env.PUBLISH_DIR}}/*.zip
${{env.PUBLISH_DIR}}/*.iso ${{env.PUBLISH_DIR}}/*.iso

22
chr.sh
View File

@@ -61,9 +61,9 @@ select_language() {
MSG_GATEWAY="Gateway:" MSG_GATEWAY="Gateway:"
MSG_DNS="Domain Name Server:" MSG_DNS="Domain Name Server:"
MSG_SELECT_VERSION="Select the version you want to install:" MSG_SELECT_VERSION="Select the version you want to install:"
MSG_LTS="long-term (v7)"
MSG_STABLE="stable (v7)" MSG_STABLE="stable (v7)"
MSG_TEST="testing (v7)" MSG_LTS6="long-term (v6)"
MSG_LTS="long-term (v6)"
MSG_STABLE6="stable (v6)" MSG_STABLE6="stable (v6)"
MSG_PLEASE_CHOOSE="Please choose an option:" MSG_PLEASE_CHOOSE="Please choose an option:"
MSG_UNSUPPORTED_ARCH="Error: Unsupported architecture: " MSG_UNSUPPORTED_ARCH="Error: Unsupported architecture: "
@@ -92,9 +92,9 @@ select_language() {
MSG_GATEWAY="网关地址:" MSG_GATEWAY="网关地址:"
MSG_DNS="DNS服务器:" MSG_DNS="DNS服务器:"
MSG_SELECT_VERSION="请选择您要安装的版本:" MSG_SELECT_VERSION="请选择您要安装的版本:"
MSG_LTS="长期支持版 (v7)"
MSG_STABLE="稳定版 (v7)" MSG_STABLE="稳定版 (v7)"
MSG_TEST="测试版 (v7)" MSG_LTS6="长期支持版 (v6)"
MSG_LTS="长期支持版 (v6)"
MSG_STABLE6="稳定版 (v6)" MSG_STABLE6="稳定版 (v6)"
MSG_PLEASE_CHOOSE="请选择一个选项:" MSG_PLEASE_CHOOSE="请选择一个选项:"
MSG_UNSUPPORTED_ARCH="错误: 不支持的架构: " MSG_UNSUPPORTED_ARCH="错误: 不支持的架构: "
@@ -207,15 +207,15 @@ select_version() {
x86_64|i386|i486|i586|i686) x86_64|i386|i486|i586|i686)
echo "$MSG_SELECT_VERSION" echo "$MSG_SELECT_VERSION"
echo "1. $MSG_STABLE" echo "1. $MSG_STABLE"
echo "2. $MSG_TEST" echo "2. $MSG_LTS"
echo "3. $MSG_LTS" echo "3. $MSG_STABLE6"
echo "4. $MSG_STABLE6" echo "4. $MSG_LTS6"
read -p "$MSG_PLEASE_CHOOSE [1-4]" version_choice read -p "$MSG_PLEASE_CHOOSE [1-4]" version_choice
;; ;;
aarch64) aarch64)
echo "$MSG_SELECT_VERSION" echo "$MSG_SELECT_VERSION"
echo "1. $MSG_STABLE" echo "1. $MSG_STABLE"
echo "2. $MSG_TEST" echo "2. $MSG_LTS"
read -p "$MSG_PLEASE_CHOOSE [1-2]" version_choice read -p "$MSG_PLEASE_CHOOSE [1-2]" version_choice
;; ;;
*) *)
@@ -229,7 +229,7 @@ select_version() {
V7=1 V7=1
;; ;;
2) 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 V7=1
;; ;;
3) 3)
@@ -237,7 +237,7 @@ select_version() {
echo "$MSG_ARM64_NOT_SUPPORT_V6" echo "$MSG_ARM64_NOT_SUPPORT_V6"
continue continue
fi 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 V7=0
;; ;;
4) 4)
@@ -245,7 +245,7 @@ select_version() {
echo "$MSG_ARM64_NOT_SUPPORT_V6" echo "$MSG_ARM64_NOT_SUPPORT_V6"
continue continue
fi 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 V7=0
;; ;;
*) *)

View File

@@ -779,13 +779,6 @@ step_install() {
return 1 return 1
fi 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 # Active boot partition
printf '\x80' | dd of="$TARGET_DISK" bs=1 seek=446 conv=notrunc >> "$LOG_FILE" 2>&1 || { 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" step_msg "[ 33%] [ERR] Step 3/8: Failed to Active boot partition on $TARGET_DISK"
@@ -793,10 +786,10 @@ step_install() {
return 1 return 1
} }
# Clear the 3rd partition entry generated by sgdisk --hybrid # Must be 0x83, otherwise "ERROR: could not find disk!"
dd if=/dev/zero of="$TARGET_DISK" bs=1 seek=478 count=16 conv=notrunc >> "$LOG_FILE" 2>&1 || { printf '\x83' | dd of="$TARGET_DISK" bs=1 seek=450 conv=notrunc >> "$LOG_FILE" 2>&1 || {
step_msg "[ 33%] [ERR] Failed to clear 3rd MBR partition entry on $TARGET_DISK" step_msg "[ 33%] [ERR] Step 3/8: Failed to change partition type on $TARGET_DISK"
echo "dd failed to clear 3rd MBR partition entry on $TARGET_DISK" > "$ERR_FILE" echo "dd failed to change partition type on $TARGET_DISK" > "$ERR_FILE"
return 1 return 1
} }