forked from confidential-containers/cloud-api-adaptor
-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (181 loc) · 6.54 KB
/
caa_build_and_push_per_arch.yaml
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
name: (Callable) Build and push cloud-api-adaptor image
on:
workflow_call:
inputs:
registry:
default: 'quay.io/confidential-containers'
description: 'Image registry (e.g. "quay.io/confidential-containers") where the built image will be pushed to'
required: false
type: string
dev_tags:
default: ''
description: 'Comma-separated list of tags for the dev built image (e.g. latest,ci-dev). By default uses the values from hack/build.sh'
required: false
type: string
release_tags:
default: ''
description: 'Likewise but for the release built image'
required: false
type: string
git_ref:
default: 'main'
description: Git ref to checkout the cloud-api-adaptor repository. Defaults to main.
required: false
type: string
defaults:
run:
working-directory: src/cloud-api-adaptor
jobs:
upload_tags:
runs-on: ubuntu-24.04
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "${{ inputs.git_ref }}"
- name: Create tags.txt
run: |
# Matches expected logic in ./hack/build.sh
commit=$(git rev-parse HEAD)
dev_tags=${{ inputs.dev_tags }}
release_tags=${{ inputs.release_tags }}
echo "dev_tags=${dev_tags:-latest,dev-${commit}}" > tags.txt
echo "release_tags=${release_tags:-${commit}}" >> tags.txt
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: image-tags
retention-days: 1
path: |
src/cloud-api-adaptor/tags.txt
build_push_job:
name: build and push
needs: [upload_tags]
runs-on: ${{ matrix.type == 'dev-s390x' && 's390x' || 'ubuntu-24.04' }}
strategy:
fail-fast: false
matrix:
include:
- type: dev-amd64
arches: "linux/amd64"
- type: dev-s390x
arches: "linux/s390x"
- type: dev-ppc64le
arches: "linux/ppc64le"
- type: release-amd64
arches: "linux/amd64"
- type: release-s390x
arches: "linux/s390x"
- type: release-ppc64le
arches: "linux/ppc64le"
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "${{ inputs.git_ref }}"
- name: Read properties from versions.yaml
run: |
go_version="$(yq '.tools.golang' versions.yaml)"
[ -n "$go_version" ]
echo "GO_VERSION=${go_version}" >> "$GITHUB_ENV"
- name: Setup Golang version ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: "**/go.sum"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install build dependencies
if: ${{ startsWith(matrix.type, 'dev-') }}
run: |
sudo apt-get update -y
sudo apt-get install -y libvirt-dev
- name: Login to quay Container Registry
if: ${{ startsWith(inputs.registry, 'quay.io') }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ startsWith(inputs.registry, 'ghcr.io') }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push dev image
if: ${{ startsWith(matrix.type, 'dev-') }}
uses: nick-fields/retry@v3
with:
# We are not interested in timeout but this field is required
# so setting to 4x the time it usually take to complete.
timeout_minutes: 60
retry_wait_seconds: 120
max_attempts: 3
command: |
echo "Build and push dev image with libvirt"
cd src/cloud-api-adaptor && ARCHES=${{matrix.arches}} RELEASE_BUILD=false DEV_TAGS=${{ inputs.dev_tags}} make image-with-arch registry=${{ inputs.registry }}
- name: Build and push release image
if: ${{ startsWith(matrix.type, 'release-') }}
uses: nick-fields/retry@v3
with:
# We are not interested in timeout but this field is required
# so setting to 4x the time it usually take to complete.
timeout_minutes: 60
retry_wait_seconds: 120
max_attempts: 3
command: |
echo "Build and push release image without libvirt"
cd src/cloud-api-adaptor && ARCHES=${{matrix.arches}} RELEASE_BUILD=true RELEASE_TAGS=${{ inputs.release_tags}} make image-with-arch registry=${{ inputs.registry }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: tags-architectures-${{matrix.type}}
retention-days: 1
path: |
src/cloud-api-adaptor/tags-architectures-*
manifest_job:
name: generate images manifest
runs-on: ubuntu-24.04
needs: [build_push_job]
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "${{ inputs.git_ref }}"
- name: Download release tags.txt
uses: actions/download-artifact@v4
with:
name: image-tags
path: src/cloud-api-adaptor
- name: Download release commits file
uses: actions/download-artifact@v4
with:
pattern: tags-architectures-*
merge-multiple: true
path: src/cloud-api-adaptor/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to quay Container Registry
if: ${{ startsWith(inputs.registry, 'quay.io') }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ startsWith(inputs.registry, 'ghcr.io') }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image manifest
env:
registry: ${{ inputs.registry }}
run: |
hack/image-manifest.sh