Refactor code structure for improved readability and maintainability

This commit is contained in:
cita
2026-03-02 14:37:49 +08:00
parent f6389a999a
commit a3f55a83f9
11 changed files with 212 additions and 26 deletions
+92 -10
View File
@@ -151,12 +151,22 @@ jobs:
generate_release_notes: true
files: release-assets/*
publish-docker:
name: Publish Docker Images
publish-docker-arch:
name: Publish Docker Image (${{ matrix.arch }})
needs: build-packages
runs-on: ubuntu-latest
timeout-minutes: 30
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
if: startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-latest
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout
@@ -169,9 +179,6 @@ jobs:
exit 1
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -199,12 +206,87 @@ jobs:
type=ref,event=tag
type=raw,value=latest
- name: Build and push multi-arch images
- name: Add architecture suffix to tags
id: arch-tags
shell: bash
run: |
set -euo pipefail
rm -f tags.txt
while IFS= read -r tag; do
[ -n "$tag" ] || continue
echo "${tag}-${{ matrix.arch }}" >> tags.txt
done <<< "${{ steps.meta.outputs.tags }}"
{
echo 'tags<<EOF'
cat tags.txt
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Build and push ${{ matrix.platform }} image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.arch-tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=release-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=release-${{ matrix.arch }}
publish-docker:
name: Publish Docker Manifests
needs: publish-docker-arch
runs-on: ubuntu-latest
timeout-minutes: 15
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ensure Docker Hub secrets are configured
run: |
if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "Missing Docker Hub secrets: DOCKERHUB_USERNAME / DOCKERHUB_TOKEN"
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
1467078763/metapi
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Create multi-arch manifests
shell: bash
run: |
set -euo pipefail
while IFS= read -r tag; do
[ -n "$tag" ] || continue
docker buildx imagetools create \
--tag "$tag" \
"${tag}-amd64" \
"${tag}-arm64"
done <<< "${{ steps.meta.outputs.tags }}"