55 tags :
66 - " v*"
77 pull_request :
8+ workflow_dispatch :
9+ inputs :
10+ tag :
11+ description : " Version tag to release (e.g. v1.2.3 or v1.2.3-dev.1)"
12+ required : true
13+ type : string
814
915permissions :
1016 contents : read
3642 name : Build (dockerhub, linux/${{ matrix.arch }})
3743 runs-on : ${{ matrix.runner }}
3844 needs : [build]
39- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
45+ if : ( github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
4046 strategy :
4147 matrix :
4248 include :
6268
6369 - name : Extract version
6470 id : meta
65- run : echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
71+ run : |
72+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
73+ TAG="${{ github.event.inputs.tag }}"
74+ else
75+ TAG="${GITHUB_REF_NAME}"
76+ fi
77+ echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
6678
6779 - name : Build and push
6880 uses : useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.0
7688 name : Build (swr, linux/${{ matrix.arch }})
7789 runs-on : ${{ matrix.runner }}
7890 needs : [build]
79- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
91+ if : ( github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
8092 strategy :
8193 matrix :
8294 include :
@@ -103,7 +115,13 @@ jobs:
103115
104116 - name : Extract version
105117 id : meta
106- run : echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
118+ run : |
119+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
120+ TAG="${{ github.event.inputs.tag }}"
121+ else
122+ TAG="${GITHUB_REF_NAME}"
123+ fi
124+ echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
107125
108126 - name : Build and push
109127 uses : useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.0
@@ -130,14 +148,26 @@ jobs:
130148
131149 - name : Create multi-arch manifest
132150 run : |
133- VERSION=${GITHUB_REF_NAME#v}
134- docker buildx imagetools create \
135- -t docker.io/zeabur/stratus:${VERSION} \
136- -t docker.io/zeabur/stratus:${VERSION%.*} \
137- -t docker.io/zeabur/stratus:${VERSION%%.*} \
138- -t docker.io/zeabur/stratus:latest \
139- docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
140- docker.io/zeabur/stratus:${VERSION}-linux-arm64
151+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
152+ TAG="${{ github.event.inputs.tag }}"
153+ else
154+ TAG="${GITHUB_REF_NAME}"
155+ fi
156+ VERSION="${TAG#v}"
157+ if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
158+ docker buildx imagetools create \
159+ -t docker.io/zeabur/stratus:${VERSION} \
160+ -t docker.io/zeabur/stratus:${VERSION%.*} \
161+ -t docker.io/zeabur/stratus:${VERSION%%.*} \
162+ -t docker.io/zeabur/stratus:latest \
163+ docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
164+ docker.io/zeabur/stratus:${VERSION}-linux-arm64
165+ else
166+ docker buildx imagetools create \
167+ -t docker.io/zeabur/stratus:${VERSION} \
168+ docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
169+ docker.io/zeabur/stratus:${VERSION}-linux-arm64
170+ fi
141171
142172 push-swr :
143173 name : Push to Huawei SWR
@@ -157,12 +187,24 @@ jobs:
157187
158188 - name : Create multi-arch manifest
159189 run : |
160- VERSION=${GITHUB_REF_NAME#v}
190+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
191+ TAG="${{ github.event.inputs.tag }}"
192+ else
193+ TAG="${GITHUB_REF_NAME}"
194+ fi
195+ VERSION="${TAG#v}"
161196 REGISTRY=swr.cn-east-3.myhuaweicloud.com
162- docker buildx imagetools create \
163- -t ${REGISTRY}/zeabur/stratus:${VERSION} \
164- -t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \
165- -t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \
166- -t ${REGISTRY}/zeabur/stratus:latest \
167- ${REGISTRY}/zeabur/stratus:${VERSION}-linux-amd64 \
168- ${REGISTRY}/zeabur/stratus:${VERSION}-linux-arm64
197+ if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
198+ docker buildx imagetools create \
199+ -t ${REGISTRY}/zeabur/stratus:${VERSION} \
200+ -t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \
201+ -t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \
202+ -t ${REGISTRY}/zeabur/stratus:latest \
203+ ${REGISTRY}/zeabur/stratus:${VERSION}-linux-amd64 \
204+ ${REGISTRY}/zeabur/stratus:${VERSION}-linux-arm64
205+ else
206+ docker buildx imagetools create \
207+ -t ${REGISTRY}/zeabur/stratus:${VERSION} \
208+ ${REGISTRY}/zeabur/stratus:${VERSION}-linux-amd64 \
209+ ${REGISTRY}/zeabur/stratus:${VERSION}-linux-arm64
210+ fi
0 commit comments