Skip to content

Commit 41f3fb0

Browse files
authored
Merge pull request #6 from jtzhpf/master
2 parents f990c6f + cab9e82 commit 41f3fb0

31 files changed

+1841
-991
lines changed

.github/workflows/docker.yml

+384
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,384 @@
1+
name: Publish Docker Image
2+
on:
3+
push:
4+
branches: [ master ]
5+
6+
concurrency:
7+
group: ${{ github.ref }}-${{ github.workflow }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
amd64_build:
12+
name: Build AMD64 Image
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout base
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v2
22+
23+
- name: Docker login
24+
uses: docker/login-action@v2
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Get commit SHA
30+
id: vars
31+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
32+
33+
- name: Build and export
34+
id: build
35+
if: github.ref == 'refs/heads/master'
36+
uses: docker/build-push-action@v3
37+
with:
38+
platforms: linux/amd64
39+
context: scripts/
40+
tags: tindy2013/subconverter:latest
41+
build-args: |
42+
SHA=${{ steps.vars.outputs.sha_short }}
43+
outputs: type=image,push=true
44+
45+
- name: Replace tag without `v`
46+
if: startsWith(github.ref, 'refs/tags/')
47+
uses: actions/github-script@v6
48+
id: version
49+
with:
50+
script: |
51+
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
52+
result-encoding: string
53+
54+
- name: Build release and export
55+
id: build_rel
56+
if: startsWith(github.ref, 'refs/tags/')
57+
uses: docker/build-push-action@v3
58+
with:
59+
platforms: linux/amd64
60+
context: scripts/
61+
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
62+
outputs: type=image,push=true
63+
64+
- name: Save digest
65+
if: github.ref == 'refs/heads/master'
66+
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
67+
68+
- name: Save release digest
69+
if: startsWith(github.ref, 'refs/tags/')
70+
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
71+
72+
- name: Upload artifact
73+
uses: actions/upload-artifact@v3
74+
with:
75+
name: digest_amd64
76+
path: /tmp/digest.txt
77+
78+
x86_build:
79+
name: Build x86 Image
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Checkout base
83+
uses: actions/checkout@v3
84+
with:
85+
fetch-depth: 0
86+
87+
- name: Set up Docker Buildx
88+
uses: docker/setup-buildx-action@v2
89+
90+
- name: Docker login
91+
uses: docker/login-action@v2
92+
with:
93+
username: ${{ secrets.DOCKER_USERNAME }}
94+
password: ${{ secrets.DOCKER_PASSWORD }}
95+
96+
- name: Get commit SHA
97+
id: vars
98+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
99+
100+
- name: Build and export
101+
id: build
102+
if: github.ref == 'refs/heads/master'
103+
uses: docker/build-push-action@v3
104+
with:
105+
platforms: linux/386
106+
context: scripts/
107+
tags: tindy2013/subconverter:latest
108+
build-args: |
109+
SHA=${{ steps.vars.outputs.sha_short }}
110+
outputs: type=image,push=true
111+
112+
- name: Replace tag without `v`
113+
if: startsWith(github.ref, 'refs/tags/')
114+
uses: actions/github-script@v6
115+
id: version
116+
with:
117+
script: |
118+
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
119+
result-encoding: string
120+
121+
- name: Build release and export
122+
id: build_rel
123+
if: startsWith(github.ref, 'refs/tags/')
124+
uses: docker/build-push-action@v3
125+
with:
126+
platforms: linux/386
127+
context: scripts/
128+
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
129+
outputs: type=image,push=true
130+
131+
- name: Save digest
132+
if: github.ref == 'refs/heads/master'
133+
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
134+
135+
- name: Save release digest
136+
if: startsWith(github.ref, 'refs/tags/')
137+
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
138+
139+
- name: Upload artifact
140+
uses: actions/upload-artifact@v3
141+
with:
142+
name: digest_386
143+
path: /tmp/digest.txt
144+
145+
armv7_build:
146+
name: Build ARMv7 Image
147+
runs-on: [self-hosted, linux, ARM64]
148+
steps:
149+
- name: Checkout base
150+
uses: actions/checkout@v3
151+
with:
152+
fetch-depth: 0
153+
154+
- name: Set up QEMU
155+
uses: docker/setup-qemu-action@v2
156+
157+
- name: Set up Docker Buildx
158+
uses: docker/setup-buildx-action@v2
159+
160+
- name: Docker login
161+
uses: docker/login-action@v2
162+
with:
163+
username: ${{ secrets.DOCKER_USERNAME }}
164+
password: ${{ secrets.DOCKER_PASSWORD }}
165+
166+
- name: Get commit SHA
167+
id: vars
168+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
169+
170+
- name: Build and export
171+
id: build
172+
if: github.ref == 'refs/heads/master'
173+
uses: docker/build-push-action@v3
174+
with:
175+
platforms: linux/arm/v7
176+
context: scripts/
177+
tags: tindy2013/subconverter:latest
178+
build-args: |
179+
SHA=${{ steps.vars.outputs.sha_short }}
180+
THREADS=2
181+
outputs: type=image,push=true
182+
183+
- name: Replace tag without `v`
184+
if: startsWith(github.ref, 'refs/tags/')
185+
uses: actions/github-script@v6
186+
id: version
187+
with:
188+
script: |
189+
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
190+
result-encoding: string
191+
192+
- name: Build release and export
193+
id: build_rel
194+
if: startsWith(github.ref, 'refs/tags/')
195+
uses: docker/build-push-action@v3
196+
with:
197+
platforms: linux/arm/v7
198+
context: scripts/
199+
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
200+
build-args: |
201+
THREADS=2
202+
outputs: type=image,push=true
203+
204+
- name: Save digest
205+
if: github.ref == 'refs/heads/master'
206+
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
207+
208+
- name: Save release digest
209+
if: startsWith(github.ref, 'refs/tags/')
210+
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
211+
212+
- name: Upload artifact
213+
uses: actions/upload-artifact@v3
214+
with:
215+
name: digest_armv7
216+
path: /tmp/digest.txt
217+
218+
arm64_build:
219+
name: Build ARM64 Image
220+
runs-on: [self-hosted, linux, ARM64]
221+
steps:
222+
- name: Checkout base
223+
uses: actions/checkout@v3
224+
with:
225+
fetch-depth: 0
226+
227+
- name: Set up QEMU
228+
uses: docker/setup-qemu-action@v2
229+
230+
- name: Set up Docker Buildx
231+
uses: docker/setup-buildx-action@v2
232+
233+
- name: Docker login
234+
uses: docker/login-action@v2
235+
with:
236+
username: ${{ secrets.DOCKER_USERNAME }}
237+
password: ${{ secrets.DOCKER_PASSWORD }}
238+
239+
- name: Get commit SHA
240+
id: vars
241+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
242+
243+
- name: Build and export
244+
id: build
245+
if: github.ref == 'refs/heads/master'
246+
uses: docker/build-push-action@v3
247+
with:
248+
platforms: linux/arm64
249+
context: scripts/
250+
tags: tindy2013/subconverter:latest
251+
build-args: |
252+
SHA=${{ steps.vars.outputs.sha_short }}
253+
THREADS=2
254+
outputs: type=image,push=true
255+
256+
- name: Replace tag without `v`
257+
if: startsWith(github.ref, 'refs/tags/')
258+
uses: actions/github-script@v6
259+
id: version
260+
with:
261+
script: |
262+
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
263+
result-encoding: string
264+
265+
- name: Build release and export
266+
id: build_rel
267+
if: startsWith(github.ref, 'refs/tags/')
268+
uses: docker/build-push-action@v3
269+
with:
270+
platforms: linux/arm64
271+
context: scripts/
272+
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
273+
build-args: |
274+
THREADS=2
275+
outputs: type=image,push=true
276+
277+
- name: Save digest
278+
if: github.ref == 'refs/heads/master'
279+
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
280+
281+
- name: Save release digest
282+
if: startsWith(github.ref, 'refs/tags/')
283+
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
284+
285+
- name: Upload artifact
286+
uses: actions/upload-artifact@v3
287+
with:
288+
name: digest_arm64
289+
path: /tmp/digest.txt
290+
291+
build:
292+
name: Build
293+
needs: [amd64_build, x86_build, armv7_build, arm64_build]
294+
runs-on: ubuntu-latest
295+
steps:
296+
- name: Checkout base
297+
uses: actions/checkout@v3
298+
with:
299+
fetch-depth: 0
300+
301+
# https://github.com/docker/setup-qemu-action
302+
- name: Set up QEMU
303+
uses: docker/setup-qemu-action@v2
304+
305+
# https://github.com/docker/setup-buildx-action
306+
- name: Set up Docker Buildx
307+
uses: docker/setup-buildx-action@v2
308+
with:
309+
config-inline: |
310+
[worker.oci]
311+
max-parallelism = 1
312+
313+
- name: Download artifact
314+
uses: actions/download-artifact@v3
315+
with:
316+
path: /tmp/images/
317+
318+
# - name: Load image
319+
# if: github.ref == 'refs/heads/master'
320+
# run: |
321+
# docker load --input /tmp/image_amd64/image_amd64.tar
322+
# docker load --input /tmp/image_386/image_386.tar
323+
# docker load --input /tmp/image_armv7/image_armv7.tar
324+
# docker load --input /tmp/image_arm64/image_arm64.tar
325+
# docker image ls -a
326+
327+
- name: Docker login
328+
uses: docker/login-action@v2
329+
with:
330+
username: ${{ secrets.DOCKER_USERNAME }}
331+
password: ${{ secrets.DOCKER_PASSWORD }}
332+
333+
# - name: Get commit SHA
334+
# id: vars
335+
# run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
336+
337+
# - name: Docker buildx image and push on master branch
338+
# if: github.ref == 'refs/heads/master'
339+
# uses: docker/build-push-action@v3
340+
# with:
341+
# platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/386
342+
# context: scripts/
343+
# tags: tindy2013/subconverter:latest
344+
# build-args: |
345+
# SHA=${{ steps.vars.outputs.sha_short }}
346+
# THREADS=1
347+
# outputs: |
348+
# type=image,push=true
349+
350+
- name: Replace tag without `v`
351+
if: startsWith(github.ref, 'refs/tags/')
352+
uses: actions/github-script@v6
353+
id: version
354+
with:
355+
script: |
356+
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
357+
result-encoding: string
358+
359+
# - name: Load release image
360+
# if: startsWith(github.ref, 'refs/tags/')
361+
# run: |
362+
# docker load --input /tmp/image_amd64/image_amd64_release.tar
363+
# docker load --input /tmp/image_386/image_386_release.tar
364+
# docker load --input /tmp/image_armv7/image_armv7_release.tar
365+
# docker load --input /tmp/image_arm64/image_arm64_release.tar
366+
# docker image ls -a
367+
368+
# - name: Docker buildx image and push on release
369+
# if: startsWith(github.ref, 'refs/tags/')
370+
# uses: docker/build-push-action@v3
371+
# with:
372+
# platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/386
373+
# context: scripts/
374+
# tags: tindy2013/subconverter:${{steps.version.outputs.result}}
375+
# build-args: THREADS=1
376+
# outputs: type=image,push=true
377+
378+
- name: Merge and push manifest on master branch
379+
if: github.ref == 'refs/heads/master'
380+
run: python scripts/merge_manifest.py
381+
382+
- name: Merge and push manifest on release
383+
if: startsWith(github.ref, 'refs/tags/')
384+
run: python scripts/merge_manifest.py ${{steps.version.outputs.result}}

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
subconverter.exe
22
.vscode
3+
libcron
4+
quickjspp
5+
*.a
6+
CMakeFiles
7+
subconverter
8+
Makefile
9+
CMakeCache.txt
10+
cmake_install.cmake
11+
toml11
12+
yaml-cpp
13+
base/cache

0 commit comments

Comments
 (0)