forked from XRPLF/ci
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (227 loc) · 8.98 KB
/
ubuntu.yml
File metadata and controls
233 lines (227 loc) · 8.98 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
name: Ubuntu
on:
pull_request:
paths:
- .github/workflows/ubuntu.yml
- docker/ubuntu/Dockerfile
- test
push:
branches:
- main
paths:
- .github/workflows/ubuntu.yml
- docker/ubuntu/Dockerfile
- test
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
PUSH: ${{ github.event_name == 'push' }}
CONTAINER_REGISTRY: ghcr.io
BUILDKIT_PROGRESS: plain
FALLBACK_GCC: 12
FALLBACK_CLANG: 16
CCACHE_VERSION: 4.12.2
CMAKE_VERSION: 4.2.1
CONAN_VERSION: 2.24.0
GCOVR_VERSION: 8.3
MOLD_VERSION: 2.40.4
RUST_VERSION: 1.91.1
jobs:
# Build the Docker image for Ubuntu using different versions of GCC and Clang.
# See https://documentation.ubuntu.com/ubuntu-for-developers/reference/availability/gcc/.
# Note, the `os` part of matrix must be kept in sync with the `merge` job below
build:
strategy:
matrix:
architecture:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
os:
- release: jammy
compiler_name: gcc
compiler_version: 12
- release: noble
compiler_name: gcc
compiler_version: 13
- release: noble
compiler_name: gcc
compiler_version: 14
- release: noble
compiler_name: clang
compiler_version: 16
- release: noble
compiler_name: clang
compiler_version: 17
- release: noble
compiler_name: clang
compiler_version: 18
- release: noble
compiler_name: clang
compiler_version: 19
- release: noble
compiler_name: clang
compiler_version: 20
runs-on: ${{ matrix.architecture.runner }}
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to GitHub Registry
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare environment
run: |
# Convert the repository name to lowercase as the organization name is
# uppercase, which is not permitted by the Docker registry. It's 2025 and GitHub
# still does not provide convenient action expression syntax for lowercase.
GITHUB_REPO=${{ github.repository }}
CONTAINER_REPO=${GITHUB_REPO@L}
echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/ubuntu-${{ matrix.os.release }}" >> $GITHUB_ENV
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/ubuntu-${{ matrix.os.release }}" >> $GITHUB_ENV
PLATFORM=${{ matrix.architecture.platform }}
echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV
- name: Prepare container metadata
id: meta
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor
with:
images: ${{ env.CONTAINER_IMAGE }}
tags: |
type=raw,value=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
type=sha,prefix=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-sha-
labels: |
org.opencontainers.image.authors=For inquiries, please use https://${{ github.repository }}/issues
org.opencontainers.image.documentation=https://${{ github.repository }}
org.opencontainers.image.vendor=XRPLF
org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }}
- name: Build and push the Docker image
id: build
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
build-args: |
BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom
BUILDKIT_INLINE_CACHE=1
UBUNTU_VERSION=${{ matrix.os.release }}
CLANG_VERSION=${{ matrix.os.compiler_name == 'clang' && matrix.os.compiler_version || env.FALLBACK_CLANG }}
GCC_VERSION=${{ matrix.os.compiler_name == 'gcc' && matrix.os.compiler_version || env.FALLBACK_GCC }}
CCACHE_VERSION=${{ env.CCACHE_VERSION }}
CMAKE_VERSION=${{ env.CMAKE_VERSION }}
CONAN_VERSION=${{ env.CONAN_VERSION }}
GCOVR_VERSION=${{ env.GCOVR_VERSION }}
MOLD_VERSION=${{ env.MOLD_VERSION }}
RUST_VERSION=${{ env.RUST_VERSION }}
context: .
file: docker/ubuntu/Dockerfile
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }}
platforms: ${{ matrix.architecture.platform }}
provenance: mode=max
push: ${{ env.PUSH }}
sbom: true
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.os.compiler_name }}
- name: Export digest
if: ${{ env.PUSH }}
run: |
mkdir -p /tmp/digests
DIGEST="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${DIGEST#sha256:}"
- name: Upload digest
if: ${{ env.PUSH }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
if: ${{ github.event_name == 'push' }}
strategy:
matrix:
os:
- release: jammy
compiler_name: gcc
compiler_version: 12
- release: noble
compiler_name: gcc
compiler_version: 13
- release: noble
compiler_name: gcc
compiler_version: 14
- release: noble
compiler_name: clang
compiler_version: 16
- release: noble
compiler_name: clang
compiler_version: 17
- release: noble
compiler_name: clang
compiler_version: 18
- release: noble
compiler_name: clang
compiler_version: 19
- release: noble
compiler_name: clang
compiler_version: 20
runs-on: ubuntu-24.04
needs:
- build
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Download digests
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: /tmp/digests
pattern: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to GitHub Registry
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare environment
run: |
GITHUB_REPO=${{ github.repository }}
CONTAINER_REPO=${GITHUB_REPO@L}
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/ubuntu-${{ matrix.os.release }}" >> $GITHUB_ENV
- name: Prepare container metadata
id: meta
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
with:
images: ${{ env.CONTAINER_IMAGE }}
tags: |
type=raw,value=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
type=sha,prefix=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-sha-
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
eval "docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(jq -cr '.annotations | map("--annotation \"" + . + "\"") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)"
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }}