Compare commits

..

No commits in common. "e07ec52d3476d6ba36296ee4d51a4438a4cbae75" and "57f2724d69157c50f7d03bd3e7f9cedeb1283518" have entirely different histories.

View File

@ -2,6 +2,16 @@ name: Build CHR Docker
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
channel:
description: 'Channel (stable, long-term, testing, development)'
required: true
default: 'stable'
type: choice
options:
- stable
- long-term
- testing
- development
version: version:
description: "Specify version (e.g., 7.19.2), empty for latest" description: "Specify version (e.g., 7.19.2), empty for latest"
required: false required: false
@ -11,66 +21,29 @@ on:
permissions: permissions:
packages: write packages: write
jobs: 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: Build:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
needs: Prepare
strategy:
max-parallel: 1
matrix:
include: ${{ fromJson(needs.Prepare.outputs.MATRIX) }}
env: env:
TZ: 'Asia/Shanghai' TZ: 'Asia/Shanghai'
VERSION: ${{ matrix.version }} CHANNEL: ${{ inputs.channel }}
CHANNEL: ${{ matrix.channel }} VERSION: ${{ inputs.version }}
IMAGE: "ghcr.io/${{ github.repository_owner }}/chr" IMAGE: "ghcr.io/${{ github.repository_owner }}/chr"
DOCKER_BUILD_SUMMARY: 'false' IS_LATEST: 'false'
DOCKER_BUILD_RECORD_UPLOAD: 'false'
steps: steps:
- name: Show build info - name: Check Version
id: version
run: | run: |
echo "Version: ${{ env.VERSION }}" if [ -z "$VERSION" ]; then
echo "Channel: ${{ env.CHANNEL }}" 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
- name: Download CHR image - name: Download CHR image
run: | run: |
@ -210,22 +183,11 @@ jobs:
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
provenance: false provenance: false
sbom: 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 channel tags - name: Update :latest tag for stable channel
if: env.CHANNEL != '' if: env.IS_LATEST == 'true'
run: | run: |
TAGS="-t ${{ env.IMAGE }}:${{ env.CHANNEL }}" docker buildx imagetools create -t ${{ env.IMAGE }}:latest ${{ env.IMAGE }}:${{ env.VERSION }}
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 - name: Save Docker Image as tar
run: | run: |
@ -241,6 +203,6 @@ jobs:
- name: Upload tar artifact - name: Upload tar artifact
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v7
with: with:
name: chr-${{ env.VERSION }}-docker-images name: chr-docker-image
path: artifacts/ path: artifacts/*.tar
retention-days: 30 archive: false