-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (178 loc) · 7.21 KB
/
Copy pathrelease.yml
File metadata and controls
208 lines (178 loc) · 7.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: Release
on:
push:
tags:
- "v*"
pull_request:
workflow_dispatch:
inputs:
tag:
description: "Version tag to release (e.g. v1.2.3 or v1.2.3-dev.1)"
required: true
type: string
permissions:
contents: read
actions: write
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
name: Build (linux/amd64)
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0
- name: Build
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.0
with:
platforms: linux/amd64
push: false
prepare:
name: Prepare release metadata
runs-on: blacksmith-2vcpu-ubuntu-2404
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
outputs:
version: ${{ steps.version.outputs.value }}
dockerhub-tags: ${{ steps.dockerhub.outputs.tags }}
swr-tags: ${{ steps.swr.outputs.tags }}
steps:
- name: Resolve tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "value=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "value=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
- name: Extract version
id: version
run: |
TAG="${{ steps.tag.outputs.value }}"
echo "value=${TAG#v}" >> "$GITHUB_OUTPUT"
- name: Docker Hub metadata
id: dockerhub
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: docker.io/zeabur/stratus
flavor: latest=auto
tags: |
type=semver,pattern={{version}},value=${{ steps.tag.outputs.value }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.tag.outputs.value }}
type=semver,pattern={{major}},value=${{ steps.tag.outputs.value }}
- name: SWR metadata
id: swr
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
with:
images: swr.cn-east-3.myhuaweicloud.com/zeabur/stratus
flavor: latest=auto
tags: |
type=semver,pattern={{version}},value=${{ steps.tag.outputs.value }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.tag.outputs.value }}
type=semver,pattern={{major}},value=${{ steps.tag.outputs.value }}
build-release-dockerhub:
name: Build (dockerhub, linux/${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: [build, prepare]
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: blacksmith-2vcpu-ubuntu-2404
- arch: arm64
platform: linux/arm64
runner: blacksmith-2vcpu-ubuntu-2404-arm
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.0
with:
platforms: ${{ matrix.platform }}
provenance: "true"
push: true
tags: docker.io/zeabur/stratus:${{ needs.prepare.outputs.version }}-linux-${{ matrix.arch }}
build-release-swr:
name: Build (swr, linux/${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: [build, prepare]
strategy:
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: blacksmith-2vcpu-ubuntu-2404
- arch: arm64
platform: linux/arm64
runner: blacksmith-2vcpu-ubuntu-2404-arm
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0
- name: Login to Huawei SWR
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: swr.cn-east-3.myhuaweicloud.com
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
password: ${{ secrets.HUAWEI_SWR_TOKEN }}
- name: Build and push
uses: useblacksmith/build-push-action@fb9e3e6a9299c78462bfadd0d93352c316adc9b8 # v2.2.0
with:
platforms: ${{ matrix.platform }}
provenance: "false"
push: true
tags: swr.cn-east-3.myhuaweicloud.com/zeabur/stratus:${{ needs.prepare.outputs.version }}-linux-${{ matrix.arch }}
push-dockerhub:
name: Push to Docker Hub
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
needs: [prepare, build-release-dockerhub]
steps:
- name: Set up Docker Buildx
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create multi-arch manifest
run: |
VERSION="${{ needs.prepare.outputs.version }}"
readarray -t TAGS < <(echo "${{ needs.prepare.outputs.dockerhub-tags }}")
TAG_ARGS=()
for t in "${TAGS[@]}"; do TAG_ARGS+=(-t "$t"); done
docker buildx imagetools create "${TAG_ARGS[@]}" \
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
docker.io/zeabur/stratus:${VERSION}-linux-arm64
push-swr:
name: Push to Huawei SWR
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
needs: [prepare, build-release-swr]
steps:
- name: Set up Docker Buildx
uses: useblacksmith/setup-docker-builder@722e97d12b1d06a961800dd6c05d79d951ad3c80 # v1.8.0
- name: Login to Huawei SWR
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: swr.cn-east-3.myhuaweicloud.com
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
password: ${{ secrets.HUAWEI_SWR_TOKEN }}
- name: Create multi-arch manifest
run: |
VERSION="${{ needs.prepare.outputs.version }}"
readarray -t TAGS < <(echo "${{ needs.prepare.outputs.swr-tags }}")
TAG_ARGS=()
for t in "${TAGS[@]}"; do TAG_ARGS+=(-t "$t"); done
docker buildx imagetools create "${TAG_ARGS[@]}" \
swr.cn-east-3.myhuaweicloud.com/zeabur/stratus:${VERSION}-linux-amd64 \
swr.cn-east-3.myhuaweicloud.com/zeabur/stratus:${VERSION}-linux-arm64