-
Notifications
You must be signed in to change notification settings - Fork 1
279 lines (271 loc) · 11.2 KB
/
ci.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
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
name: ci
on:
workflow_dispatch:
inputs:
environment:
description: 'Select the GPG pubkey and the HSM keys to use'
required: true
default: 'test'
type: choice
options:
- test
- prod
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
pull_request:
push:
branches:
- main
tags:
- '**'
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build:
runs-on: [self-hosted, lab, he, simple, X64]
env:
GPG_PUBKEY: ${{ github.event.inputs.environment || 'test' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU for Docker Buildkit
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
- name: Run grub build (make ci)
run: make ci
- name: Upload onie-grubx64.efi
uses: actions/upload-artifact@v3
with:
name: onie-grubx64.efi
path: artifacts/onie-grubx64.efi
- name: Upload onie-recovery-grubx64.efi
uses: actions/upload-artifact@v3
with:
name: onie-recovery-grubx64.efi
path: artifacts/onie-recovery-grubx64.efi
- name: Upload sonic-grubx64.efi
uses: actions/upload-artifact@v3
with:
name: sonic-grubx64.efi
path: artifacts/sonic-grubx64.efi
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true
build-arm64:
runs-on: [self-hosted, simple, ARM64]
env:
GPG_PUBKEY: ${{ github.event.inputs.environment || 'test' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU for Docker Buildkit
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
- name: Run grub build (make ci-arm64)
run: make ci-arm64
- name: Upload onie-grubaa64.efi
uses: actions/upload-artifact@v3
with:
name: onie-grubaa64.efi
path: artifacts/onie-grubaa64.efi
- name: Upload onie-recovery-grubaa64.efi
uses: actions/upload-artifact@v3
with:
name: onie-recovery-grubaa64.efi
path: artifacts/onie-recovery-grubaa64.efi
- name: Upload sonic-grubaa64.efi
uses: actions/upload-artifact@v3
with:
name: sonic-grubaa64.efi
path: artifacts/sonic-grubaa64.efi
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true
signing:
needs: [build, build-arm64]
runs-on: [self-hosted, lab, he, simple, jammy]
environment: ${{ github.event.inputs.environment || 'test' }}
env:
HSM_AUTH_KEY: ${{ secrets.HSM_AUTH_KEY }}
HSM_AUTH_KEY_SLOT: ${{ secrets.HSM_AUTH_KEY_SLOT }}
ORAS_VERSION: "1.0.0"
ORAS_ARTIFACT_TAG: ${{ github.event.inputs.environment || 'test' }}
steps:
- name: Install sbsign tool
run: |
sudo apt-get update
sudo apt install -y sbsigntool
- name: Install YubiHSM client and PKC11 dependencies
run: |
# this is the PKCS11 engine module for OpenSSL
sudo apt install -y libengine-pkcs11-openssl
# install dependencies
sudo apt install -y libusb-1.0-0 libpcsclite1 libusb-1.0-0
# download the yubihsm-shell package, it is all we need, and install all debs
wget https://developers.yubico.com/yubihsm-shell/Releases/yubihsm-shell-2.4.1-ubuntu2204-amd64.tar.gz
tar xf yubihsm-shell-2.4.1-ubuntu2204-amd64.tar.gz
cd yubihsm-shell
sudo apt-get install -y -f ./libyubihsm-usb1_2.4.1_amd64.deb
sudo apt-get install -y -f ./libyubihsm-http1_2.4.1_amd64.deb
sudo apt-get install -y -f ./libyubihsm1_2.4.1_amd64.deb
sudo apt-get install -y -f ./libyubihsm-dev_2.4.1_amd64.deb
sudo apt-get install -y -f ./libykhsmauth1_2.4.1_amd64.deb
sudo apt-get install -y -f ./yubihsm-pkcs11_2.4.1_amd64.deb
sudo apt-get install -y -f ./yubihsm-auth_2.4.1_amd64.deb
sudo apt-get install -y -f ./yubihsm-shell_2.4.1_amd64.deb
sudo apt-get install -y -f ./yubihsm-wrap_2.4.1_amd64.deb
cd
- name: Prepare HSM and PKCS11 configuration files
run: |
# writes the YubiHSM specific PKCS11 config file which will be used by the YubiHSM PKCS11 module
# if the YUBIHSM_PKCS11_CONF environment variable is set
cat > $PWD/yubihsm_pkcs11.conf <<EOF
connector = ${{ vars.HSM_CONNECTOR_URL }}
timeout = 5
EOF
# writes an OpenSSL configuration file. We will be using it by setting the OPENSSL_CONF environment
# variable which will always take priority if set.
cat > $PWD/openssl-pkcs11-engine.conf <<EOF
openssl_conf = openssl_init
[openssl_init]
engines = engine_section
[engine_section]
pkcs11 = pkcs11_section
[pkcs11_section]
engine_id = pkcs11
# not necessary, if it is, it is most likely at here
#dynamic_path = /usr/lib/x86_64-linux-gnu/engines-1.1/pkcs11.so
MODULE_PATH = /usr/lib/x86_64-linux-gnu/pkcs11/yubihsm_pkcs11.so
EOF
- name: Set up YUBIHSM_PKCS11_CONF env var
run: |
echo "YUBIHSM_PKCS11_CONF=$PWD/yubihsm_pkcs11.conf" >> $GITHUB_ENV
- name: Set up OPENSSL_CONF env var
run: |
echo "OPENSSL_CONF=$PWD/openssl-pkcs11-engine.conf" >> $GITHUB_ENV
- name: Prepare SB Signing cert
run: |
echo "${{ vars.SB_SIGNING_CERT }}" > sb-signing-cert.pem
- name: Prepare PKCS11 Key URI
run: |
PKCS11_KEY_URI=$( python -c 'import os; print(os.path.expandvars("${{ vars.PKCS11_KEY_URI }}"))' )
echo "::add-mask::$PKCS11_KEY_URI"
echo "PKCS11_KEY_URI=$PKCS11_KEY_URI" >> $GITHUB_ENV
- name: Download onie-grubx64.efi from build job
uses: actions/download-artifact@v3
with:
name: onie-grubx64.efi
- name: Download onie-recovery-grubx64.efi from build job
uses: actions/download-artifact@v3
with:
name: onie-recovery-grubx64.efi
- name: Download sonic-grubx64.efi from build job
uses: actions/download-artifact@v3
with:
name: sonic-grubx64.efi
- name: Download onie-grubaa64.efi from build job
uses: actions/download-artifact@v3
with:
name: onie-grubaa64.efi
- name: Download onie-recovery-grubaa64.efi from build job
uses: actions/download-artifact@v3
with:
name: onie-recovery-grubaa64.efi
- name: Download sonic-grubaa64.efi from build job
uses: actions/download-artifact@v3
with:
name: sonic-grubaa64.efi
- name: Sign all EFI grub binaries
run: |
sbsign --engine pkcs11 --cert sb-signing-cert.pem --key $PKCS11_KEY_URI onie-grubx64.efi
sbsign --engine pkcs11 --cert sb-signing-cert.pem --key $PKCS11_KEY_URI onie-recovery-grubx64.efi
sbsign --engine pkcs11 --cert sb-signing-cert.pem --key $PKCS11_KEY_URI sonic-grubx64.efi
sbsign --engine pkcs11 --cert sb-signing-cert.pem --key $PKCS11_KEY_URI onie-grubaa64.efi
sbsign --engine pkcs11 --cert sb-signing-cert.pem --key $PKCS11_KEY_URI onie-recovery-grubaa64.efi
sbsign --engine pkcs11 --cert sb-signing-cert.pem --key $PKCS11_KEY_URI sonic-grubaa64.efi
- name: Upload onie-grubx64.efi.signed
uses: actions/upload-artifact@v3
with:
name: onie-grubx64.efi.signed
path: onie-grubx64.efi.signed
- name: Upload onie-recovery-grubx64.efi.signed
uses: actions/upload-artifact@v3
with:
name: onie-recovery-grubx64.efi.signed
path: onie-recovery-grubx64.efi.signed
- name: Upload sonic-grubx64.efi.signed
uses: actions/upload-artifact@v3
with:
name: sonic-grubx64.efi.signed
path: sonic-grubx64.efi.signed
- name: Upload onie-grubaa64.efi.signed
uses: actions/upload-artifact@v3
with:
name: onie-grubaa64.efi.signed
path: onie-grubaa64.efi.signed
- name: Upload onie-recovery-grubaa64.efi.signed
uses: actions/upload-artifact@v3
with:
name: onie-recovery-grubaa64.efi.signed
path: onie-recovery-grubaa64.efi.signed
- name: Upload sonic-grubaa64.efi.signed
uses: actions/upload-artifact@v3
with:
name: sonic-grubaa64.efi.signed
path: sonic-grubaa64.efi.signed
- name: Install oras
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
run: |
curl -LO "https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz"
mkdir -p oras-install/
tar -zxf oras_${ORAS_VERSION}_*.tar.gz -C oras-install/
sudo mv oras-install/oras /usr/local/bin/
rm -rf oras_${ORAS_VERSION}_*.tar.gz oras-install/
- name: oras login
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
run: |
oras login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Push oras artifacts
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
run: |
mkdir oras_artifact
cp -v onie-grubx64.efi.signed oras_artifact/onie-grubx64.efi
cp -v onie-recovery-grubx64.efi.signed oras_artifact/onie-recovery-grubx64.efi
cp -v sonic-grubx64.efi.signed oras_artifact/sonic-grubx64.efi
cp -v onie-grubaa64.efi.signed oras_artifact/onie-grubaa64.efi
cp -v onie-recovery-grubaa64.efi.signed oras_artifact/onie-recovery-grubaa64.efi
cp -v sonic-grubaa64.efi.signed oras_artifact/sonic-grubaa64.efi
cd oras_artifact
oras push ghcr.io/githedgehog/grub-build:${ORAS_ARTIFACT_TAG} \
onie-grubx64.efi \
onie-recovery-grubx64.efi \
sonic-grubx64.efi \
onie-grubaa64.efi \
onie-recovery-grubaa64.efi \
sonic-grubaa64.efi
- name: Setup tmate session for debug
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
with:
limit-access-to-actor: true