-
Notifications
You must be signed in to change notification settings - Fork 98
201 lines (177 loc) · 6.72 KB
/
publish-artifacts.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
name: Publish artifacts with ORAS
on:
push:
branches:
- main
env:
RUST_TOOLCHAIN: 1.83.0
jobs:
publish-aa:
permissions:
contents: read
packages: write
id-token: write
attestations: write
strategy:
matrix:
platform: [
{ tee: none, arch: x86_64, libc: musl },
{ tee: none, arch: s390x, libc: gnu },
{ tee: none, arch: aarch64, libc: gnu },
{ tee: amd, arch: x86_64, libc: musl },
{ tee: az-cvm-vtpm, arch: x86_64, libc: gnu },
{ tee: tdx, arch: x86_64, libc: gnu },
{ tee: cca, arch: x86_64, libc: musl },
{ tee: cca, arch: aarch64, libc: gnu },
{ tee: se, arch: s390x, libc: gnu },
]
runs-on: ${{ matrix.platform.arch == 's390x' && 's390x' || 'ubuntu-24.04' }}
env:
TEE_PLATFORM: ${{ matrix.platform.tee }}
LIBC: ${{ matrix.platform.libc }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RUST_TARGET: ${{ matrix.platform.arch }}-unknown-linux-${{ matrix.platform.libc }}
steps:
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: oras-project/setup-oras@v1
with:
version: 1.2.0
if: matrix.platform.arch != 's390x'
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ env.RUST_TARGET }}
override: true
- name: Install tpm dependencies
if: matrix.platform.tee == 'az-cvm-vtpm'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libtss2-dev
- uses: ./.github/actions/install-intel-dcap
with:
ubuntu-version: noble
if: matrix.platform.tee == 'tdx'
- uses: actions/checkout@v4
- name: Build
env:
ARCH: ${{ matrix.platform.arch }}
run: make ./target/${{ env.RUST_TARGET }}/release/attestation-agent
- name: Publish with ORAS
id: publish
env:
OCI_ARCH: ${{ matrix.platform.arch == 'x86_64' && 'amd64' || matrix.platform.arch == 'aarch64' && 'arm64' || matrix.platform.arch }}
run: |
mkdir oras
cd oras
cp ../target/${{ env.RUST_TARGET }}/release/attestation-agent .
tar cJf attestation-agent.tar.xz attestation-agent
arch_tag="${{ github.sha }}-${{ matrix.platform.tee }}_${{ matrix.platform.arch }}"
image="${REGISTRY}/${IMAGE_NAME}/attestation-agent"
tag="${{ github.sha }}-${{ matrix.platform.tee }}"
oras push "${image}:${arch_tag}" attestation-agent.tar.xz
# We need to create the platform annotations with docker, since oras 1.2 doesn't support
# pushing with platform yet.
docker manifest create "${image}:${tag}" --amend "${image}:${arch_tag}"
docker manifest annotate --arch "$OCI_ARCH" --os linux "${image}:${tag}" "${image}:${arch_tag}"
docker manifest push "${image}:${tag}"
# add image and digest to output for attestation
echo "image=${image}" >> "$GITHUB_OUTPUT"
digest="$(oras manifest fetch "${image}:${arch_tag}" --descriptor | jq -r .digest)"
echo "digest=${digest}" >> "$GITHUB_OUTPUT"
- uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ steps.publish.outputs.image }}
subject-digest: ${{ steps.publish.outputs.digest }}
push-to-registry: true
publish-cdh-and-asr:
permissions:
contents: read
packages: write
id-token: write
attestations: write
strategy:
matrix:
arch:
- x86_64
- s390x
- aarch64
include:
- arch: x86_64
libc: musl
- arch: s390x
libc: gnu
- arch: aarch64
libc: gnu
runs-on: ${{ matrix.arch == 's390x' && 's390x' || 'ubuntu-24.04' }}
env:
LIBC: ${{ matrix.libc }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
RUST_TARGET: ${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}
steps:
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: oras-project/setup-oras@v1
with:
version: 1.2.0
if: matrix.arch != 's390x'
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ env.RUST_TARGET }}
override: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libdevmapper-dev \
protobuf-compiler
- uses: actions/checkout@v4
- name: Build CDH
env:
ARCH: ${{ matrix.arch }}
run: make ./target/${{ env.RUST_TARGET }}/release/confidential-data-hub
- name: Build ASR
env:
ARCH: ${{ matrix.arch }}
run: make ./target/${{ env.RUST_TARGET }}/release/api-server-rest
- name: Publish CDH + ASR with ORAS
id: publish
run: |
tag="${{ github.sha }}-${{ matrix.arch }}"
mkdir oras
cd oras
cp ../target/${{ env.RUST_TARGET }}/release/{confidential-data-hub,api-server-rest} .
tar cJf confidential-data-hub.tar.xz confidential-data-hub
image="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/confidential-data-hub"
oras push "${image}:${tag}" confidential-data-hub.tar.xz
echo "cdh-image=${image}" >> "$GITHUB_OUTPUT"
digest="$(oras manifest fetch "${image}:${tag}" --descriptor | jq -r .digest)"
echo "cdh-digest=${digest}" >> "$GITHUB_OUTPUT"
tar cJf api-server-rest.tar.xz api-server-rest
image="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/api-server-rest"
oras push "${image}:${tag}" api-server-rest.tar.xz
echo "asr-image=${image}" >> "$GITHUB_OUTPUT"
digest="$(oras manifest fetch "${image}:${tag}" --descriptor | jq -r .digest)"
echo "asr-digest=${digest}" >> "$GITHUB_OUTPUT"
- uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ steps.publish.outputs.cdh-image }}
subject-digest: ${{ steps.publish.outputs.cdh-digest }}
push-to-registry: true
- uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ steps.publish.outputs.asr-image }}
subject-digest: ${{ steps.publish.outputs.asr-digest }}
push-to-registry: true