Compare commits

...

17 Commits

Author SHA1 Message Date
elseif
e07ec52d34 modified: .github/workflows/build_docker.yml 2026-07-16 14:45:52 +08:00
elseif
bf73ab201b modified: .github/workflows/build_docker.yml 2026-07-16 14:42:38 +08:00
elseif
ae7943de83 modified: .github/workflows/build_docker.yml 2026-07-16 14:26:58 +08:00
elseif
3b42f1c5fb modified: .github/workflows/build_docker.yml 2026-07-16 14:22:52 +08:00
elseif
7b273f0464 modified: .github/workflows/build_docker.yml 2026-07-16 14:01:06 +08:00
elseif
5033270988 modified: .github/workflows/build_docker.yml 2026-07-16 13:54:42 +08:00
elseif
063cd7785f modified: .github/workflows/build_docker.yml 2026-07-16 13:28:07 +08:00
elseif
b628eaadd2 modified: .github/workflows/build_docker.yml 2026-07-16 13:25:36 +08:00
elseif
4d32f80f8b modified: .github/workflows/build_docker.yml 2026-07-16 13:19:44 +08:00
elseif
e576f75398 modified: .github/workflows/build_docker.yml 2026-07-16 13:15:39 +08:00
elseif
c7eba4be0c modified: .github/workflows/build_docker.yml 2026-07-16 13:14:00 +08:00
elseif
78a2720c82 modified: .github/workflows/build_docker.yml 2026-07-16 13:10:22 +08:00
elseif
9cc32db4d2 modified: .github/workflows/build_docker.yml 2026-07-16 12:47:25 +08:00
elseif
4f3f8b5e40 modified: .github/workflows/build_docker.yml 2026-07-16 12:43:14 +08:00
elseif
68e9f1f5c2 modified: .github/workflows/build_docker.yml 2026-07-16 12:14:25 +08:00
elseif
a46286d886 modified: .github/workflows/build_docker.yml 2026-07-16 10:03:43 +08:00
elseif
e44ea1504b modified: .github/workflows/build_docker.yml 2026-07-16 09:59:39 +08:00

View File

@ -2,16 +2,6 @@ name: Build CHR Docker
on:
workflow_dispatch:
inputs:
channel:
description: 'Channel (stable, long-term, testing, development)'
required: true
default: 'stable'
type: choice
options:
- stable
- long-term
- testing
- development
version:
description: "Specify version (e.g., 7.19.2), empty for latest"
required: false
@ -21,29 +11,66 @@ on:
permissions:
packages: write
jobs:
Prepare:
runs-on: ubuntu-24.04
outputs:
MATRIX: ${{ steps.get_versions.outputs.MATRIX }}
steps:
- name: Get versions and generate matrix
id: get_versions
run: |
VERSION="${{ inputs.version }}"
if [ -n "$VERSION" ]; then
MATRIX=$(jq -c -n '
[
{ "version": $VERSION, "channel": ""}
]
' --arg VERSION "$VERSION")
else
TIMESTAMP=$(date +%s)
LONG_TERM=$(wget -nv -O - "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.long-term?t=$TIMESTAMP" | cut -d ' ' -f1)
STABLE=$(wget -nv -O - "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.stable?t=$TIMESTAMP" | cut -d ' ' -f1)
echo "Long-term version: $LONG_TERM"
echo "Stable version: $STABLE"
if [ -z "$LONG_TERM" ]; then
echo "Failed to get long-term version"
exit 1
fi
if [ -z "$STABLE" ]; then
echo "Failed to get stable version"
exit 1
fi
MATRIX=$(jq -c -n '
[
{version: $LONG_TERM, channel: "long-term"},
{version: $STABLE, channel: "stable"}
]
' --arg LONG_TERM "$LONG_TERM" --arg STABLE "$STABLE")
fi
echo "Generated matrix: $MATRIX"
echo "MATRIX=$MATRIX" >> $GITHUB_OUTPUT
Build:
runs-on: ubuntu-24.04
needs: Prepare
strategy:
max-parallel: 1
matrix:
include: ${{ fromJson(needs.Prepare.outputs.MATRIX) }}
env:
TZ: 'Asia/Shanghai'
CHANNEL: ${{ inputs.channel }}
VERSION: ${{ inputs.version }}
VERSION: ${{ matrix.version }}
CHANNEL: ${{ matrix.channel }}
IMAGE: "ghcr.io/${{ github.repository_owner }}/chr"
IS_LATEST: 'false'
DOCKER_BUILD_SUMMARY: 'false'
DOCKER_BUILD_RECORD_UPLOAD: 'false'
steps:
- name: Check Version
id: version
- name: Show build info
run: |
if [ -z "$VERSION" ]; then
echo "Checking latest version from $CHANNEL channel..."
TIMESTAMP=$(date +%s)
NEWEST=$(wget -nv -O - "https://upgrade.mikrotik.ltd/routeros/NEWESTa7.$CHANNEL?t=$TIMESTAMP")
VERSION=$(echo "$NEWEST" | cut -d ' ' -f1)
echo "Latest version: $VERSION"
if [ "$CHANNEL" = "stable" ]; then
echo "IS_LATEST=true" >> $GITHUB_ENV
fi
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Version: ${{ env.VERSION }}"
echo "Channel: ${{ env.CHANNEL }}"
- name: Download CHR image
run: |
@ -183,11 +210,22 @@ jobs:
cache-to: type=gha,mode=max
provenance: false
sbom: false
outputs: >
type=image,
annotation-index.org.opencontainers.image.title=MikroTik CHR RouterOS,
annotation-index.org.opencontainers.image.description=MikroTik CHR (Cloud Hosted Router) running on QEMU with Docker,
annotation-index.org.opencontainers.image.version=${{ env.VERSION }},
annotation-index.org.opencontainers.image.url=https://mikrotik.ltd
- name: Update :latest tag for stable channel
if: env.IS_LATEST == 'true'
- name: Update channel tags
if: env.CHANNEL != ''
run: |
docker buildx imagetools create -t ${{ env.IMAGE }}:latest ${{ env.IMAGE }}:${{ env.VERSION }}
TAGS="-t ${{ env.IMAGE }}:${{ env.CHANNEL }}"
if [ "${{ env.CHANNEL }}" = "stable" ]; then
TAGS="$TAGS -t ${{ env.IMAGE }}:latest"
fi
echo "Creating tags: $TAGS"
docker buildx imagetools create $TAGS ${{ env.IMAGE }}:${{ env.VERSION }}
- name: Save Docker Image as tar
run: |
@ -203,6 +241,6 @@ jobs:
- name: Upload tar artifact
uses: actions/upload-artifact@v7
with:
name: chr-docker-image
path: artifacts/*.tar
archive: false
name: chr-${{ env.VERSION }}-docker-images
path: artifacts/
retention-days: 30