-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (127 loc) · 5.41 KB
/
Copy pathrelease.yml
File metadata and controls
151 lines (127 loc) · 5.41 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
name: Release
on:
push:
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: read
actions: write
concurrency:
group: release-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-amd64:
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: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version
id: meta
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
platforms: linux/amd64
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-arm64:
name: Build (linux/arm64)
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version
id: meta
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
with:
platforms: linux/arm64
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
tags: docker.io/zeabur/stratus:${{ steps.meta.outputs.version }}-linux-arm64
cache-from: type=gha,scope=buildkit-linux-arm64
cache-to: type=gha,mode=max,scope=buildkit-linux-arm64
push-dockerhub:
name: Push to Docker Hub
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
needs: [build-amd64, build-arm64]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.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=${GITHUB_REF_NAME#v}
docker buildx imagetools create \
-t docker.io/zeabur/stratus:${VERSION} \
-t docker.io/zeabur/stratus:${VERSION%.*} \
-t docker.io/zeabur/stratus:${VERSION%%.*} \
-t docker.io/zeabur/stratus:latest \
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: [build-amd64, build-arm64]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- 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: Retag to SWR
run: |
VERSION=${GITHUB_REF_NAME#v}
REGISTRY=swr.cn-east-3.myhuaweicloud.com
docker buildx imagetools create \
-t ${REGISTRY}/zeabur/stratus:${VERSION} \
-t ${REGISTRY}/zeabur/stratus:${VERSION%.*} \
-t ${REGISTRY}/zeabur/stratus:${VERSION%%.*} \
-t ${REGISTRY}/zeabur/stratus:latest \
docker.io/zeabur/stratus:${VERSION}-linux-amd64 \
docker.io/zeabur/stratus:${VERSION}-linux-arm64