Skip to content

Commit 63e44fc

Browse files
pan93412claude
andcommitted
ci: restructure release workflow with gated matrix builds
Add a fast linux/amd64 gate build that runs on every PR/push, then fan out to a 4-way matrix (dockerhub + swr × amd64 + arm64) only on tag pushes. SWR builds use provenance=false to satisfy registry requirements; push-swr now pulls directly from SWR per-arch images instead of retagging from Docker Hub. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 596f4e4 commit 63e44fc

1 file changed

Lines changed: 56 additions & 48 deletions

File tree

.github/workflows/release.yml

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1717

1818
jobs:
19-
build-amd64:
19+
build:
2020
name: Build (linux/amd64)
2121
runs-on: blacksmith-2vcpu-ubuntu-2404
2222

@@ -27,34 +27,46 @@ jobs:
2727
- name: Set up Docker Buildx
2828
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
2929

30-
- name: Login to Docker Hub
31-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
32-
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
33-
with:
34-
username: ${{ secrets.DOCKERHUB_USERNAME }}
35-
password: ${{ secrets.DOCKERHUB_TOKEN }}
36-
37-
- name: Extract version
38-
id: meta
39-
run: |
40-
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
41-
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
42-
else
43-
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
44-
fi
45-
46-
- name: Build and push
30+
- name: Build
4731
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
4832
with:
4933
platforms: linux/amd64
50-
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
51-
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-amd64
34+
push: false
5235
cache-from: type=gha,scope=buildkit-linux-amd64
5336
cache-to: type=gha,mode=max,scope=buildkit-linux-amd64
5437

55-
build-arm64:
56-
name: Build (linux/arm64)
57-
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
38+
build-release:
39+
name: Build (${{ matrix.registry }}, linux/${{ matrix.arch }})
40+
runs-on: ${{ matrix.runner }}
41+
needs: [build]
42+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
43+
strategy:
44+
matrix:
45+
include:
46+
- registry: dockerhub
47+
arch: amd64
48+
platform: linux/amd64
49+
runner: blacksmith-2vcpu-ubuntu-2404
50+
tag_prefix: docker.io/zeabur/stratus
51+
provenance: "true"
52+
- registry: dockerhub
53+
arch: arm64
54+
platform: linux/arm64
55+
runner: blacksmith-2vcpu-ubuntu-2404-arm
56+
tag_prefix: docker.io/zeabur/stratus
57+
provenance: "true"
58+
- registry: swr
59+
arch: amd64
60+
platform: linux/amd64
61+
runner: blacksmith-2vcpu-ubuntu-2404
62+
tag_prefix: swr.cn-east-3.myhuaweicloud.com/zeabur/stratus
63+
provenance: "false"
64+
- registry: swr
65+
arch: arm64
66+
platform: linux/arm64
67+
runner: blacksmith-2vcpu-ubuntu-2404-arm
68+
tag_prefix: swr.cn-east-3.myhuaweicloud.com/zeabur/stratus
69+
provenance: "false"
5870

5971
steps:
6072
- name: Checkout
@@ -64,35 +76,38 @@ jobs:
6476
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
6577

6678
- name: Login to Docker Hub
67-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
79+
if: matrix.registry == 'dockerhub'
6880
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
6981
with:
7082
username: ${{ secrets.DOCKERHUB_USERNAME }}
7183
password: ${{ secrets.DOCKERHUB_TOKEN }}
7284

85+
- name: Login to Huawei SWR
86+
if: matrix.registry == 'swr'
87+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
88+
with:
89+
registry: swr.cn-east-3.myhuaweicloud.com
90+
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
91+
password: ${{ secrets.HUAWEI_SWR_TOKEN }}
92+
7393
- name: Extract version
7494
id: meta
75-
run: |
76-
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
77-
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
78-
else
79-
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
80-
fi
95+
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
8196

8297
- name: Build and push
8398
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
8499
with:
85-
platforms: linux/arm64
86-
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
87-
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-arm64
88-
cache-from: type=gha,scope=buildkit-linux-arm64
89-
cache-to: type=gha,mode=max,scope=buildkit-linux-arm64
100+
platforms: ${{ matrix.platform }}
101+
provenance: ${{ matrix.provenance }}
102+
push: true
103+
tags: ${{ matrix.tag_prefix }}:${{ steps.meta.outputs.version }}-linux-${{ matrix.arch }}
104+
cache-from: type=gha,scope=buildkit-linux-amd64,type=gha,scope=buildkit-${{ matrix.registry }}-linux-${{ matrix.arch }}
105+
cache-to: type=gha,mode=max,scope=buildkit-${{ matrix.registry }}-linux-${{ matrix.arch }}
90106

91107
push-dockerhub:
92108
name: Push to Docker Hub
93109
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
94-
needs: [build-amd64, build-arm64]
95-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
110+
needs: [build-release]
96111

97112
steps:
98113
- name: Set up Docker Buildx
@@ -118,27 +133,20 @@ jobs:
118133
push-swr:
119134
name: Push to Huawei SWR
120135
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
121-
needs: [build-amd64, build-arm64]
122-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
136+
needs: [build-release]
123137

124138
steps:
125139
- name: Set up Docker Buildx
126140
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
127141

128-
- name: Login to Docker Hub
129-
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
130-
with:
131-
username: ${{ secrets.DOCKERHUB_USERNAME }}
132-
password: ${{ secrets.DOCKERHUB_TOKEN }}
133-
134142
- name: Login to Huawei SWR
135143
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
136144
with:
137145
registry: swr.cn-east-3.myhuaweicloud.com
138146
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
139147
password: ${{ secrets.HUAWEI_SWR_TOKEN }}
140148

141-
- name: Retag to SWR
149+
- name: Create multi-arch manifest
142150
run: |
143151
VERSION=${GITHUB_REF_NAME#v}
144152
REGISTRY=swr.cn-east-3.myhuaweicloud.com
@@ -147,5 +155,5 @@ jobs:
147155
-t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \
148156
-t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \
149157
-t ${REGISTRY}/zeabur/stratus:latest \
150-
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
151-
docker.io/zeabur/stratus:${VERSION}-linux-arm64
158+
${REGISTRY}/zeabur/stratus:${VERSION}-linux-amd64 \
159+
${REGISTRY}/zeabur/stratus:${VERSION}-linux-arm64

0 commit comments

Comments
 (0)