mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-06 00:33:57 +08:00
feat: 多架构构建
This commit is contained in:
49
.github/workflows/backend-ci-cd.yml
vendored
49
.github/workflows/backend-ci-cd.yml
vendored
@@ -66,6 +66,13 @@ jobs:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'pull_request'
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
arch: x86_64
|
||||
- platform: linux/arm64
|
||||
arch: aarch64
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./backend
|
||||
@@ -115,8 +122,10 @@ jobs:
|
||||
- name: Get SGP
|
||||
run: |
|
||||
mkdir -p assets/sgp
|
||||
wget -O assets/sgp/sgp https://baizhiyun.oss-cn-hangzhou.aliyuncs.com/prod/sgp/x86_64/sgp
|
||||
wget -O assets/sgp/sgp-rules https://baizhiyun.oss-cn-hangzhou.aliyuncs.com/prod/sgp/x86_64/sgp-rules
|
||||
echo "Downloading SGP for architecture: ${{ matrix.arch }}"
|
||||
wget -O assets/sgp/sgp https://baizhiyun.oss-cn-hangzhou.aliyuncs.com/prod/sgp/${{ matrix.arch }}/sgp
|
||||
wget -O assets/sgp/sgp-rules https://baizhiyun.oss-cn-hangzhou.aliyuncs.com/prod/sgp/${{ matrix.arch }}/sgp-rules
|
||||
chmod +x assets/sgp/sgp
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
@@ -137,10 +146,10 @@ jobs:
|
||||
context: ./backend
|
||||
file: ./backend/build/Dockerfile
|
||||
push: true
|
||||
platforms: linux/amd64, linux/arm64
|
||||
platforms: ${{ matrix.platform }}
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/backend:${{ steps.get_version.outputs.VERSION }}
|
||||
${{ env.REGISTRY }}/backend:latest
|
||||
${{ env.REGISTRY }}/backend:${{ steps.get_version.outputs.VERSION }}-${{ matrix.arch }}
|
||||
${{ env.REGISTRY }}/backend:latest-${{ matrix.arch }}
|
||||
build-args: |
|
||||
GOCACHE=/tmp/go-build
|
||||
GOMODCACHE=/tmp/go-mod
|
||||
@@ -149,4 +158,32 @@ jobs:
|
||||
BUILD_TIME=${{ steps.get_build_time.outputs.BUILD_TIME }}
|
||||
GIT_COMMIT=${{ steps.get_git_commit.outputs.GIT_COMMIT }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
create-manifest:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
- name: Login to Aliyun Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.CT_ALIYUN_USER }}
|
||||
password: ${{ secrets.CT_ALIYUN_PASS }}
|
||||
|
||||
- name: Create and push multi-arch manifest
|
||||
run: |
|
||||
VERSION=${{ needs.build.outputs.version }}
|
||||
|
||||
# Create and push version manifest
|
||||
docker manifest create ${{ env.REGISTRY }}/backend:${VERSION} \
|
||||
${{ env.REGISTRY }}/backend:${VERSION}-x86_64 \
|
||||
${{ env.REGISTRY }}/backend:${VERSION}-aarch64
|
||||
docker manifest push ${{ env.REGISTRY }}/backend:${VERSION}
|
||||
|
||||
# Create and push latest manifest
|
||||
docker manifest create ${{ env.REGISTRY }}/backend:latest \
|
||||
${{ env.REGISTRY }}/backend:latest-x86_64 \
|
||||
${{ env.REGISTRY }}/backend:latest-aarch64
|
||||
docker manifest push ${{ env.REGISTRY }}/backend:latest
|
||||
Reference in New Issue
Block a user