forked from Wind4/vlmcsd
-
Notifications
You must be signed in to change notification settings - Fork 2
104 lines (87 loc) · 2.9 KB
/
build.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
name: Test
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
packages: write
contents: read
jobs:
build:
name: Build image
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
deps: gcc
cc: gcc
platform: linux/amd64
- arch: arm64
deps: qemu-user-static gcc-aarch64-linux-gnu
cc: aarch64-linux-gnu-gcc
binutil: /usr/bin/qemu-aarch64-static
platform: linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install build dependencies
run: sudo apt-get install make ${{ matrix.deps }}
- name: Build binary
run: CC=${{ matrix.cc }} MAX_THREADS=2 make
- name: Login to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image metadata
id: image-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.arch }},enable={{is_default_branch}}
type=sha,enable=true,prefix=${{ matrix.arch }}-
type=sha,format=long,enable=true,prefix=${{ matrix.arch }}-
- name: Build image and push to registry
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }}
post:
name: Publish Multi-Arch Manifest
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs:
- build
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Multi-Arch Manifests
run: |
docker manifest create ${IMAGE_NAME}:latest \
--amend ${IMAGE_NAME}:{amd,arm}64
docker manifest create ${IMAGE_NAME}:${GITHUB_SHA} \
--amend ${IMAGE_NAME}:{amd,arm}64-${GITHUB_SHA}
docker manifest create ${IMAGE_NAME}:${GITHUB_SHA::7} \
--amend ${IMAGE_NAME}:{amd,arm}64-${GITHUB_SHA::7}
docker manifest push ${IMAGE_NAME}:latest
docker manifest push ${IMAGE_NAME}:${GITHUB_SHA}
docker manifest push ${IMAGE_NAME}:${GITHUB_SHA::7}