forked from TosiDrop/vm-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (205 loc) · 7.63 KB
/
publish.yml
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
209
210
211
212
name: publish
on:
push:
branches: ['master']
tags: ['v*.*.*']
concurrency: ${{ github.ref }}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository == 'TosiDrop/vm-frontend' && 'tosidrop/vm-frontend' || github.repository }}
jobs:
build-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: qemu
uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Semantic versioning from our tags
type=semver,pattern={{version}}
# tag the sha version unless we are a git tag
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }},priority=300,format=long,prefix=
- id: meta-arch
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
suffix=-amd64
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Semantic versioning from our tags
type=semver,pattern={{version}}
# tag the sha version unless we are a git tag
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }},priority=300,format=long,prefix=
- name: update version
run: |
echo "const version = \"${{ steps.meta.outputs.version }}\";" > client/src/version.ts
echo "export default version;" >> client/src/version.ts
- name: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta-arch.outputs.tags }}
labels: ${{ steps.meta-arch.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# TEMP fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# TEMP fix
# Something strange is happening with the manifests when we push which
# breaks the downstream multi-arch-manifest, so pull and push to work
# around this by resubmitting manifests
- name: pull-and-push
run: |
for t in `echo '${{ steps.meta-arch.outputs.tags }}'`; do
docker pull $t && docker push $t
done
build-arm64:
runs-on: ["self-hosted", "ARM64"]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: qemu
uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Semantic versioning from our tags
type=semver,pattern={{version}}
# tag the sha version unless we are a git tag
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }},priority=300,format=long,prefix=
- id: meta-arch
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
suffix=-arm64v8
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Semantic versioning from our tags
type=semver,pattern={{version}}
# tag the sha version unless we are a git tag
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }},priority=300,format=long,prefix=
- name: update version
run: |
echo "const version = \"${{ steps.meta.outputs.version }}\";" > client/src/version.ts
echo "export default version;" >> client/src/version.ts
- name: push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta-arch.outputs.tags }}
labels: ${{ steps.meta-arch.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# TEMP fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# TEMP fix
# Something strange is happening with the manifests when we push which
# breaks the downstream multi-arch-manifest, so pull and push to work
# around this by resubmitting manifests
- name: pull-and-push
run: |
for t in `echo '${{ steps.meta-arch.outputs.tags }}'`; do
docker pull $t && docker push $t
done
multi-arch-manifest:
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
flavor: |
latest=false
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Semantic versioning from our tags
type=semver,pattern={{version}}
# tag the sha version unless we are a git tag
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }},priority=300,format=long,prefix=
- name: manifest
run: docker manifest create ${{ steps.meta.outputs.tags }} --amend ${{ steps.meta.outputs.tags }}-amd64 --amend ${{ steps.meta.outputs.tags }}-arm64v8
- name: manifest-master
run: docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master --amend ${{ steps.meta.outputs.tags }}-amd64 --amend ${{ steps.meta.outputs.tags }}-arm64v8
if: github.ref == 'refs/heads/master'
- name: push
run: docker manifest push ${{ steps.meta.outputs.tags }}
- name: push-master
run: docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master
if: github.ref == 'refs/heads/master'
github-release:
runs-on: ubuntu-latest
needs: [multi-arch-manifest]
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/github-script@v7
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
} catch (error) {
core.setFailed(error.message);
}