-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (138 loc) · 4.3 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
name: "Publish container image"
on:
push:
tags:
- v*
release:
types:
- published
workflow_dispatch:
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v4
# with:
# fetch-tags: true
- name: Unshallow
run: git fetch --force --prune --tags --unshallow
- name: Describe the current state
run: git describe --tags --always
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=sha-${{ github.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Dockerfile
run: make Dockerfile Dockerfile.build
- name: Build auxiliary image and export to docker (linux/amd64)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.build
push: false
load: true
tags: binaries:local-linux-amd64
build-args: |
TARGET_GOOS=linux
TARGET_GOARCH=amd64
- name: Build auxiliary image and export to docker (linux/arm64)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.build
push: false
load: true
tags: binaries:local-linux-arm64
build-args: |
TARGET_GOOS=linux
TARGET_GOARCH=arm64
- name: Capture binaries
run: |
./scripts/build-os-arch --image binaries:local-linux-amd64 --no-build linux amd64
./scripts/build-os-arch --image binaries:local-linux-arm64 --no-build linux arm64
tar -czf dist/binaries.tar.gz dist/linux-amd64 dist/linux-arm64
- name: Archive binaries
uses: actions/upload-artifact@v4
with:
name: binaries
path: dist/binaries.tar.gz
retention-days: 1
publish:
name: Publish container images
runs-on: ubuntu-latest-8-cores
needs: build
steps:
- uses: actions/checkout@v4
- name: Unshallow
run: git fetch --prune --unshallow
- name: Describe the current state
run: git describe --tags --always
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{raw}}
type=sha
- name: Generate Dockerfile
run: |
make Dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# with:
# config: .github/workflows/buildkitd.toml
- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Retrieve binaries
uses: actions/download-artifact@v4
with:
name: binaries
- name: Load binaries
run: |
find -type f -print0 | xargs -0r ls -ld
tar -xzf binaries.tar.gz
- name: Build image (linux/amd64)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
load: true
platforms: linux/amd64
tags: test:local
- name: Test image
run: |
docker run --rm test:local image-test
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}