2022-10-19 07:10:15 -04:00
name : Build and Upload OS image
2023-01-23 04:59:17 -05:00
2022-10-19 07:10:15 -04:00
on :
workflow_dispatch :
inputs :
imageVersion :
description : "Semantic version including patch e.g. v<major>.<minor>.<patch> (only used for releases)"
required : false
2022-12-09 05:51:38 -05:00
isRelease :
description : 'Is this a release? (sets "ref" to special value "-")'
2022-10-19 07:10:15 -04:00
type : boolean
required : false
2022-12-09 05:51:38 -05:00
default : false
stream :
2023-01-16 06:20:01 -05:00
description : "Image stream / type. (Use 'stable' for releases, 'nightly' for regular non-release images, 'console' for images with serial console access and 'debug' for debug builds)"
2022-12-09 05:51:38 -05:00
type : choice
required : true
options :
- "debug"
2023-01-16 07:56:06 -05:00
- "console"
- "nightly"
- "stable"
2023-01-02 06:25:17 -05:00
ref :
type : string
description : "Git ref to checkout"
required : false
workflow_call :
inputs :
imageVersion :
description : "Semantic version including patch e.g. v<major>.<minor>.<patch> (only used for releases)"
required : false
type : string
isRelease :
description : 'Is this a release? (sets "ref" to special value "-")'
type : boolean
required : false
default : false
stream :
description : "Image stream / type. (Use 'stable' for releases, 'nightly' for regular non-release images and 'debug' for debug builds)"
type : string
required : true
ref :
type : string
description : "Git ref to checkout"
required : false
2022-10-19 07:10:15 -04:00
jobs :
build-dependencies :
name : "Build binaries for embedding in the OS"
runs-on : ubuntu-22.04
permissions :
contents : read
packages : read
2022-10-01 18:48:06 -04:00
outputs :
bootstrapper-sha256 : ${{ steps.collect-hashes.outputs.bootstrapper-sha256 }}
disk-mapper-sha256 : ${{ steps.collect-hashes.outputs.disk-mapper-sha256 }}
2022-12-29 11:50:11 -05:00
upgrade-agent-sha256 : ${{ steps.collect-hashes.outputs.upgrade-agent-sha256 }}
2023-03-09 09:01:09 -05:00
measurement-reader-sha256 : ${{ steps.collect-hashes.outputs.measurement-reader-sha256 }}
2022-10-19 07:10:15 -04:00
steps :
- name : Checkout
2023-05-05 08:42:20 -04:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2022-11-10 11:22:26 -05:00
with :
2023-01-02 06:25:17 -05:00
ref : ${{ inputs.ref || github.head_ref }}
2022-10-19 07:10:15 -04:00
2023-02-21 08:43:26 -05:00
- name : Setup Go environment
2023-04-04 05:06:30 -04:00
uses : actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
2023-02-21 08:43:26 -05:00
with :
2023-05-11 08:14:15 -04:00
go-version : "1.20.4"
2023-02-21 08:43:26 -05:00
cache : true
2023-03-20 11:05:08 -04:00
- name : Setup bazel
uses : ./.github/actions/setup_bazel
with :
useCache : "false"
2022-10-19 07:10:15 -04:00
- name : Build bootstrapper
2022-12-09 05:51:38 -05:00
if : inputs.stream != 'debug'
2022-10-19 07:10:15 -04:00
uses : ./.github/actions/build_bootstrapper
with :
outputPath : ${{ github.workspace }}/build/bootstrapper
- name : Build debugd
2022-12-09 05:51:38 -05:00
if : inputs.stream == 'debug'
2022-10-19 07:10:15 -04:00
uses : ./.github/actions/build_debugd
with :
2023-01-20 04:28:56 -05:00
outputPath : ${{ github.workspace }}/build/debugd
2022-10-19 07:10:15 -04:00
- name : Build disk-mapper
uses : ./.github/actions/build_disk_mapper
with :
outputPath : ${{ github.workspace }}/build/disk-mapper
2022-12-29 11:50:11 -05:00
- name : Build upgrade-agent
uses : ./.github/actions/build_upgrade_agent
with :
outputPath : ${{ github.workspace }}/build/upgrade-agent
2023-03-09 09:01:09 -05:00
- name : Build measurement-reader
uses : ./.github/actions/build_measurement_reader
with :
outputPath : ${{ github.workspace }}/build/measurement-reader
2022-10-19 07:10:15 -04:00
- name : Upload dependencies
2023-01-06 11:35:54 -05:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
2023-01-20 04:28:56 -05:00
env :
MAIN_BINARY : ${{ inputs.stream == 'debug' && 'debugd' || 'bootstrapper' }}
2022-10-19 07:10:15 -04:00
with :
name : dependencies
path : |
2023-01-20 04:28:56 -05:00
${{ github.workspace }}/build/${{ env.MAIN_BINARY }}
2022-10-19 07:10:15 -04:00
${{ github.workspace }}/build/disk-mapper
2022-12-29 11:50:11 -05:00
${{ github.workspace }}/build/upgrade-agent
2023-03-09 09:01:09 -05:00
${{ github.workspace }}/build/measurement-reader
2022-10-19 07:10:15 -04:00
- name : Collect hashes
2022-10-01 18:48:06 -04:00
id : collect-hashes
2023-01-18 04:15:58 -05:00
working-directory : ${{ github.workspace }}/build
2022-10-19 07:10:15 -04:00
run : |
2022-11-11 08:49:16 -05:00
{
2023-05-02 03:59:55 -04:00
echo "bootstrapper-sha256=$(sha256sum bootstrapper | head -c 64)"
echo "disk-mapper-sha256=$(sha256sum disk-mapper | head -c 64)"
echo "upgrade-agent-sha256=$(sha256sum upgrade-agent | head -c 64)"
echo "measurement-reader-sha256=$(sha256sum measurement-reader | head -c 64)"
2023-03-21 07:20:27 -04:00
} | tee -a "$GITHUB_OUTPUT"
2022-10-19 07:10:15 -04:00
2022-11-04 11:48:52 -04:00
build-settings :
name : "Determine build settings"
runs-on : ubuntu-22.04
outputs :
2022-12-09 05:51:38 -05:00
ref : ${{ steps.ref.outputs.ref }}
2023-01-16 07:56:06 -05:00
stream : ${{ steps.stream.outputs.stream }}
2022-11-04 11:48:52 -04:00
imageType : ${{ steps.image-type.outputs.imageType }}
pkiSet : ${{ steps.pki-set.outputs.pkiSet }}
2022-12-09 05:51:38 -05:00
imageVersion : ${{ steps.image-version.outputs.imageVersion }}
imageName : ${{ steps.image-version.outputs.imageName }}
imageNameShort : ${{ steps.image-version.outputs.imageNameShort }}
imageApiBasePath : ${{ steps.image-version.outputs.imageApiBasePath }}
2023-02-24 06:00:04 -05:00
cliApiBasePath : ${{ steps.image-version.outputs.cliApiBasePath }}
2022-11-04 11:48:52 -04:00
steps :
- name : Checkout
2023-05-05 08:42:20 -04:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2022-11-10 11:22:26 -05:00
with :
2023-01-02 06:25:17 -05:00
ref : ${{ inputs.ref || github.head_ref }}
2022-11-04 11:48:52 -04:00
- name : Determine version
id : version
uses : ./.github/actions/pseudo_version
2022-12-09 05:51:38 -05:00
- name : Determine ref
id : ref
run : |
if [[ "${{ inputs.isRelease }}" = "true" ]]; then
2023-04-14 12:25:53 -04:00
echo "ref=-" | tee -a "$GITHUB_OUTPUT"
2022-12-09 05:51:38 -05:00
else
2023-04-14 12:25:53 -04:00
echo "ref=${{ steps.version.outputs.branchName }}" | tee -a "$GITHUB_OUTPUT"
2022-12-09 05:51:38 -05:00
fi
2023-01-16 07:56:06 -05:00
- name : Determine and validate stream
id : stream
2022-12-09 05:51:38 -05:00
run : |
if [[ "${{ inputs.isRelease }}" == "true" ]] && [[ "${{ inputs.stream }}" == "nightly" ]]; then
echo "Nightly builds are not allowed for releases"
exit 1
2023-01-23 04:59:17 -05:00
fi
if [[ "${{ inputs.isRelease }}" != "true" ]] && [[ "${{ inputs.stream }}" == "stable" ]]; then
2022-12-09 05:51:38 -05:00
echo "Stable builds are only allowed for releases"
exit 1
fi
2023-04-14 12:25:53 -04:00
echo "stream=${{ inputs.stream }}" | tee -a "$GITHUB_OUTPUT"
2023-01-16 07:56:06 -05:00
2022-11-04 11:48:52 -04:00
- name : Determine type of image build
shell : bash
id : image-type
run : |
2023-01-16 07:56:06 -05:00
case "${{ steps.stream.outputs.stream }}" in
"debug" )
2023-04-14 12:25:53 -04:00
echo "imageType=debug" | tee -a "$GITHUB_OUTPUT"
2023-01-16 07:56:06 -05:00
;;
"console" )
2023-04-14 12:25:53 -04:00
echo "imageType=console" | tee -a "$GITHUB_OUTPUT"
2023-01-16 07:56:06 -05:00
;;
*)
2023-04-14 12:25:53 -04:00
echo "imageType=default" | tee -a "$GITHUB_OUTPUT"
2023-01-16 07:56:06 -05:00
;;
esac
2022-11-04 11:48:52 -04:00
- name : Determine PKI set
id : pki-set
shell : bash
run : |
2023-01-16 07:56:06 -05:00
if [[ "${{ inputs.isRelease }}" == "true" ]] && [[ "${{ steps.stream.outputs.stream }}" == "stable" ]]; then
2023-04-14 12:25:53 -04:00
echo "pkiSet=pki_prod" | tee -a "$GITHUB_OUTPUT"
2022-12-09 05:51:38 -05:00
else
2023-04-14 12:25:53 -04:00
echo "pkiSet=pki_testing" | tee -a "$GITHUB_OUTPUT"
2022-12-09 05:51:38 -05:00
fi
- name : Determine image version
id : image-version
2022-11-16 09:45:10 -05:00
shell : bash
2022-12-09 05:51:38 -05:00
env :
REF : ${{ steps.ref.outputs.ref }}
2023-01-16 07:56:06 -05:00
STREAM : ${{ steps.stream.outputs.stream }}
2023-03-14 09:53:33 -04:00
IMAGE_VERSION : ${{ inputs.imageVersion || steps.version.outputs.version }}
2022-11-16 09:45:10 -05:00
run : |
2022-12-09 05:51:38 -05:00
{
echo "imageVersion=${IMAGE_VERSION}"
echo "imageName=ref/${REF}/stream/${STREAM}/${IMAGE_VERSION}"
2023-01-04 11:07:16 -05:00
echo "imageApiBasePath=constellation/v1/ref/${REF}/stream/${STREAM}/${IMAGE_VERSION}/image"
2023-02-24 06:00:04 -05:00
echo "cliApiBasePath=constellation/v1/ref/${REF}/stream/${STREAM}/${IMAGE_VERSION}/cli"
2023-03-21 07:20:27 -04:00
} | tee -a "$GITHUB_OUTPUT"
2022-12-09 05:51:38 -05:00
2022-12-12 08:17:50 -05:00
if [[ "${REF}" = "-" ]] && [[ "${STREAM}" = "stable" ]]; then
2023-04-14 12:25:53 -04:00
echo "imageNameShort=${IMAGE_VERSION}" | tee -a "$GITHUB_OUTPUT"
2022-12-09 05:51:38 -05:00
elif [[ "${REF}" = "-" ]]; then
2023-04-14 12:25:53 -04:00
echo "imageNameShort=stream/${STREAM}/${IMAGE_VERSION}" | tee -a "$GITHUB_OUTPUT"
2022-11-16 09:45:10 -05:00
else
2023-04-14 12:25:53 -04:00
echo "imageNameShort=ref/${REF}/stream/${STREAM}/${IMAGE_VERSION}" | tee -a "$GITHUB_OUTPUT"
2022-11-16 09:45:10 -05:00
fi
2022-10-19 07:10:15 -04:00
make-os-image :
name : "Build OS using mkosi"
2022-11-04 11:48:52 -04:00
needs : [ build-settings, build-dependencies]
2022-10-19 07:10:15 -04:00
runs-on : ubuntu-22.04
2023-06-01 06:33:06 -04:00
# TODO(malt3): flatten outputs once possible
2022-10-01 18:48:06 -04:00
# https://github.com/community/community/discussions/17245
outputs :
2023-05-23 10:22:29 -04:00
image-raw-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-raw-aws-aws-nitro-tpm-sha256 }}
image-raw-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-raw-azure-azure-sev-snp-sha256 }}
image-raw-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-raw-gcp-gcp-sev-es-sha256 }}
image-raw-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-raw-qemu-qemu-vtpm-sha256 }}
image-efi-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-efi-aws-aws-nitro-tpm-sha256 }}
image-efi-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-efi-azure-azure-sev-snp-sha256 }}
image-efi-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-efi-gcp-gcp-sev-es-sha256 }}
image-efi-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-efi-qemu-qemu-vtpm-sha256 }}
image-initrd-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-initrd-aws-aws-nitro-tpm-sha256 }}
image-initrd-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-initrd-azure-azure-sev-snp-sha256 }}
image-initrd-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-initrd-gcp-gcp-sev-es-sha256 }}
image-initrd-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-initrd-qemu-qemu-vtpm-sha256 }}
image-root-raw-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-root-raw-aws-aws-nitro-tpm-sha256 }}
image-root-raw-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-root-raw-azure-azure-sev-snp-sha256 }}
image-root-raw-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-root-raw-gcp-gcp-sev-es-sha256 }}
image-root-raw-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-root-raw-qemu-qemu-vtpm-sha256 }}
image-root-verity-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-root-verity-aws-aws-nitro-tpm-sha256 }}
image-root-verity-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-root-verity-azure-azure-sev-snp-sha256 }}
image-root-verity-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-root-verity-gcp-gcp-sev-es-sha256 }}
image-root-verity-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-root-verity-qemu-qemu-vtpm-sha256 }}
image-vmlinuz-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-vmlinuz-aws-aws-nitro-tpm-sha256 }}
image-vmlinuz-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-vmlinuz-azure-azure-sev-snp-sha256 }}
image-vmlinuz-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-vmlinuz-gcp-gcp-sev-es-sha256 }}
image-vmlinuz-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-vmlinuz-qemu-qemu-vtpm-sha256 }}
image-raw-changelog-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-raw-changelog-aws-aws-nitro-tpm-sha256 }}
image-raw-changelog-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-raw-changelog-azure-azure-sev-snp-sha256 }}
image-raw-changelog-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-raw-changelog-gcp-gcp-sev-es-sha256 }}
image-raw-changelog-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-raw-changelog-qemu-qemu-vtpm-sha256 }}
image-raw-manifest-aws-aws-nitro-tpm-sha256 : ${{ steps.collect-hashes.outputs.image-raw-manifest-aws-aws-nitro-tpm-sha256 }}
image-raw-manifest-azure-azure-sev-snp-sha256 : ${{ steps.collect-hashes.outputs.image-raw-manifest-azure-azure-sev-snp-sha256 }}
image-raw-manifest-gcp-gcp-sev-es-sha256 : ${{ steps.collect-hashes.outputs.image-raw-manifest-gcp-gcp-sev-es-sha256 }}
image-raw-manifest-qemu-qemu-vtpm-sha256 : ${{ steps.collect-hashes.outputs.image-raw-manifest-qemu-qemu-vtpm-sha256 }}
2022-10-19 07:10:15 -04:00
strategy :
2022-11-03 10:22:51 -04:00
fail-fast : false
2022-10-19 07:10:15 -04:00
matrix :
2023-05-23 10:22:29 -04:00
include :
- csp : aws
attestation_variant : aws-nitro-tpm
2023-05-26 04:15:30 -04:00
- csp : aws
attestation_variant : aws-sev-snp
2023-05-23 10:22:29 -04:00
- csp : azure
attestation_variant : azure-sev-snp
- csp : gcp
attestation_variant : gcp-sev-es
- csp : gcp
attestation_variant : gcp-sev-snp
- csp : qemu
attestation_variant : qemu-vtpm
- csp : openstack
attestation_variant : qemu-vtpm
2022-10-19 07:10:15 -04:00
steps :
- name : Checkout
2023-05-05 08:42:20 -04:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2022-11-10 11:22:26 -05:00
with :
2023-01-02 06:25:17 -05:00
ref : ${{ inputs.ref || github.head_ref }}
2022-10-19 07:10:15 -04:00
- name : Download build dependencies
2023-01-06 11:35:54 -05:00
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
2022-10-19 07:10:15 -04:00
with :
name : dependencies
path : ${{ github.workspace }}/build
2023-03-09 09:01:09 -05:00
- name : Mark bootstrapper, debugd, disk-mapper, measurement-reader, and upgrade-agent as executable
2022-10-19 07:10:15 -04:00
run : |
2023-01-20 04:28:56 -05:00
chmod +x ${{ github.workspace }}/build/bootstrapper || true
chmod +x ${{ github.workspace }}/build/debugd || true
2022-10-19 07:10:15 -04:00
chmod +x ${{ github.workspace }}/build/disk-mapper
2022-12-29 11:50:11 -05:00
chmod +x ${{ github.workspace }}/build/upgrade-agent
2023-03-09 09:01:09 -05:00
chmod +x ${{ github.workspace }}/build/measurement-reader
2022-10-19 07:10:15 -04:00
- name : Setup mkosi
uses : ./.github/actions/setup_mkosi
with :
2023-04-25 12:22:40 -04:00
version : d8b32fbf3077b612db0024276e73cec3c2c87577
systemdVersion : f6e94c5f7ddd796095cf6294857e535dcdbfc677
2022-10-19 07:10:15 -04:00
- name : Prepare PKI for secure boot signing
2022-11-04 11:48:52 -04:00
id : prepare-pki
2022-10-19 07:10:15 -04:00
shell : bash
2022-10-21 04:11:53 -04:00
working-directory : ${{ github.workspace }}/image
2022-10-19 07:10:15 -04:00
env :
2022-11-04 11:48:52 -04:00
PKI_SET : ${{ needs.build-settings.outputs.pkiSet }}
2022-12-12 08:39:37 -05:00
DB_KEY : ${{ ((needs.build-settings.outputs.pkiSet == 'pki_prod') && secrets.SECURE_BOOT_RELEASE_DB_KEY) || secrets.SECURE_BOOT_TESTING_DB_KEY }}
2023-01-18 04:15:58 -05:00
run : |
echo "${DB_KEY}" > "${PKI_SET}/db.key"
2023-04-25 12:22:40 -04:00
chmod 600 "${PKI_SET}/db.key"
2023-01-18 04:15:58 -05:00
ln -s "${PKI_SET}" pki
2022-10-19 07:10:15 -04:00
- name : Build
shell : bash
2022-10-21 04:11:53 -04:00
working-directory : ${{ github.workspace }}/image
2022-10-19 07:10:15 -04:00
env :
BOOTSTRAPPER_BINARY : ${{ github.workspace }}/build/bootstrapper
2023-01-20 04:28:56 -05:00
DEBUGD_BINARY : ${{ github.workspace }}/build/bootstrapper
2022-10-19 07:10:15 -04:00
DISK_MAPPER_BINARY : ${{ github.workspace }}/build/disk-mapper
2022-12-29 11:50:11 -05:00
UPGRADE_AGENT_BINARY : ${{ github.workspace }}/build/upgrade-agent
2023-03-09 09:01:09 -05:00
MEASUREMENT_READER_BINARY : ${{ github.workspace }}/build/measurement-reader
2023-01-20 04:28:56 -05:00
DEBUG : ${{ (needs.build-settings.outputs.stream == 'debug') && 'true' || 'false' }}
2023-01-16 07:56:06 -05:00
AUTOLOGIN : ${{ (needs.build-settings.outputs.stream == 'console' || needs.build-settings.outputs.stream == 'debug' ) && 'true' || 'false' }}
2022-12-09 05:51:38 -05:00
IMAGE_VERSION : ${{ needs.build-settings.outputs.imageVersion }}
2022-10-19 07:10:15 -04:00
CSP : ${{ matrix.csp }}
2023-05-23 10:22:29 -04:00
ATTESTATION_VARIANT : ${{ matrix.attestation_variant }}
2023-01-18 04:15:58 -05:00
run : |
echo "::group::Build"
2023-05-23 10:22:29 -04:00
sudo make IMAGE_VERSION="${IMAGE_VERSION}" DEBUG="${DEBUG}" AUTOLOGIN="${AUTOLOGIN}" "${CSP}_${ATTESTATION_VARIANT}"
2023-01-18 04:15:58 -05:00
echo "::endgroup::"
2022-10-19 07:10:15 -04:00
2022-10-01 18:48:06 -04:00
- name : Collect hashes
id : collect-hashes
2023-05-23 10:22:29 -04:00
working-directory : ${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37
2022-10-01 18:48:06 -04:00
run : |
2022-11-11 08:49:16 -05:00
{
2023-05-23 10:22:29 -04:00
echo "image-raw-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.raw | head -c 64)"
echo "image-efi-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.efi | head -c 64)"
echo "image-initrd-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.esp.raw | head -c 64)"
echo "image-root-raw-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.root-x86-64.raw | head -c 64)"
echo "image-root-verity-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.root-x86-64-verity.raw | head -c 64)"
echo "image-vmlinuz-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.vmlinuz | head -c 64)"
echo "image-raw-changelog-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.changelog | head -c 64)"
echo "image-raw-manifest-${{ matrix.csp }}-${{ matrix.attestation_variant }}-sha256=$(sha256sum image.manifest | head -c 64)"
2023-03-21 07:20:27 -04:00
} | tee -a "$GITHUB_OUTPUT"
2022-10-01 18:48:06 -04:00
2022-10-19 07:10:15 -04:00
- name : Upload raw OS image as artifact
2023-01-06 11:35:54 -05:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
2022-10-19 07:10:15 -04:00
with :
2023-05-23 10:22:29 -04:00
name : image-${{ matrix.csp }}-${{ matrix.attestation_variant }}
path : ${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.raw
2022-10-19 07:10:15 -04:00
- name : Upload individual OS parts as artifacts
2023-01-06 11:35:54 -05:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
2022-10-19 07:10:15 -04:00
with :
2023-05-23 10:22:29 -04:00
name : parts-${{ matrix.csp }}-${{ matrix.attestation_variant }}
2022-10-19 07:10:15 -04:00
path : |
2023-05-23 10:22:29 -04:00
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.cmdline
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.efi
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.esp.raw
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.root-x86-64.raw
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.root-x86-64-verity.raw
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.vmlinuz
2022-10-19 07:10:15 -04:00
- name : Upload manifest as artifact
2023-01-06 11:35:54 -05:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
2022-10-19 07:10:15 -04:00
with :
2023-05-23 10:22:29 -04:00
name : manifest-${{ matrix.csp }}-${{ matrix.attestation_variant }}
2022-10-19 07:10:15 -04:00
path : |
2023-05-23 10:22:29 -04:00
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.changelog
${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.manifest
2022-10-19 07:10:15 -04:00
upload-os-image :
name : "Upload OS image to CSP"
2022-11-04 11:48:52 -04:00
needs : [ build-settings, make-os-image]
2022-10-19 07:10:15 -04:00
runs-on : ubuntu-22.04
2022-10-17 11:39:49 -04:00
permissions :
id-token : write
contents : read
2022-10-19 07:10:15 -04:00
strategy :
2022-11-03 10:22:51 -04:00
fail-fast : false
2022-10-19 07:10:15 -04:00
matrix :
2023-05-23 10:22:29 -04:00
include :
- csp : aws
attestation_variant : aws-nitro-tpm
2023-05-26 04:15:30 -04:00
- csp : aws
attestation_variant : aws-sev-snp
2023-05-23 10:22:29 -04:00
- csp : azure
attestation_variant : azure-sev-snp
- csp : gcp
attestation_variant : gcp-sev-es
- csp : gcp
attestation_variant : gcp-sev-snp
- csp : qemu
attestation_variant : qemu-vtpm
- csp : openstack
attestation_variant : qemu-vtpm
2023-04-27 05:37:37 -04:00
env :
2023-05-23 10:22:29 -04:00
RAW_IMAGE_PATH : mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image.raw
JSON_OUTPUT : mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37/image-upload.json
AZURE_IMAGE_PATH : mkosi.output.azure_${{ matrix.attestation_variant }}/fedora~37/image.vhd
GCP_IMAGE_PATH : mkosi.output.gcp_${{ matrix.attestation_variant }}/fedora~37/image.tar.gz
2023-04-27 05:37:37 -04:00
SHORTNAME : ${{ needs.build-settings.outputs.imageNameShort }}
2023-05-23 10:22:29 -04:00
ATTESTATION_VARIANT : ${{ matrix.attestation_variant }}
2022-10-19 07:10:15 -04:00
steps :
- name : Checkout
2023-05-05 08:42:20 -04:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2022-11-10 11:22:26 -05:00
with :
2023-01-02 06:25:17 -05:00
ref : ${{ inputs.ref || github.head_ref }}
2022-10-19 07:10:15 -04:00
- name : Download OS image artifact
2023-01-06 11:35:54 -05:00
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
2022-10-19 07:10:15 -04:00
with :
2023-05-23 10:22:29 -04:00
name : image-${{ matrix.csp }}-${{ matrix.attestation_variant }}
path : ${{ github.workspace }}/image/mkosi.output.${{ matrix.csp }}_${{ matrix.attestation_variant }}/fedora~37
2022-10-19 07:10:15 -04:00
- name : Install tools
shell : bash
run : |
echo "::group::Install tools"
sudo apt-get update
2022-10-17 11:39:49 -04:00
sudo apt-get install -y \
pigz \
qemu-utils \
2023-03-06 07:29:15 -05:00
python3-pip
2022-10-19 07:10:15 -04:00
echo "::endgroup::"
2022-10-17 11:39:49 -04:00
- name : Login to AWS
2023-03-21 05:56:30 -04:00
uses : aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
2022-10-17 11:39:49 -04:00
with :
role-to-assume : arn:aws:iam::795746500882:role/GitHubConstellationImagePipeline
aws-region : eu-central-1
2022-10-19 07:10:15 -04:00
- name : Login to Azure
2022-11-08 10:21:08 -05:00
if : matrix.csp == 'azure'
2022-11-08 10:13:10 -05:00
uses : ./.github/actions/login_azure
2022-10-19 07:10:15 -04:00
with :
2022-10-21 10:23:29 -04:00
azure_credentials : ${{ secrets.AZURE_CREDENTIALS }}
2022-10-19 07:10:15 -04:00
- name : Login to GCP
2022-12-09 05:51:38 -05:00
if : matrix.csp == 'gcp'
2023-01-18 04:15:58 -05:00
uses : ./.github/actions/login_gcp
2022-10-19 07:10:15 -04:00
with :
2023-01-16 12:15:17 -05:00
service_account : "constellation-cos-builder@constellation-331613.iam.gserviceaccount.com"
2022-10-19 07:10:15 -04:00
- name : Prepare PKI for image upload
2022-11-04 11:48:52 -04:00
id : prepare-pki
2022-10-19 07:10:15 -04:00
shell : bash
2023-01-18 04:15:58 -05:00
working-directory : ${{ github.workspace }}/image
2022-10-19 07:10:15 -04:00
run : |
2022-11-04 11:48:52 -04:00
ln -s ${{ needs.build-settings.outputs.pkiSet }} pki
2022-10-19 07:10:15 -04:00
2022-10-17 11:39:49 -04:00
- name : Upload AWS image
2023-01-18 04:15:58 -05:00
if : matrix.csp == 'aws'
2022-10-17 11:39:49 -04:00
shell : bash
working-directory : ${{ github.workspace }}/image
2023-01-18 04:15:58 -05:00
run : |
echo "::group::Upload AWS image"
2023-05-23 10:22:29 -04:00
bazel run //image/upload -- image aws \
2023-04-27 05:37:37 -04:00
--verbose \
2023-05-23 10:22:29 -04:00
--raw-image "${RAW_IMAGE_PATH}" \
--attestation-variant "${ATTESTATION_VARIANT}" \
2023-04-27 05:37:37 -04:00
--version "${SHORTNAME}" \
2023-05-23 10:22:29 -04:00
--out "${JSON_OUTPUT}"
echo -e "Uploaded AWS image: \n\n\`\`\`\n$(jq < "${JSON_OUTPUT}")\n\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
2023-01-18 04:15:58 -05:00
echo "::endgroup::"
2022-10-19 07:10:15 -04:00
- name : Upload GCP image
2023-01-18 04:15:58 -05:00
if : matrix.csp == 'gcp'
2022-10-19 07:10:15 -04:00
shell : bash
2022-10-21 04:11:53 -04:00
working-directory : ${{ github.workspace }}/image
2023-01-18 04:15:58 -05:00
run : |
echo "::group::Upload GCP image"
2023-05-23 10:22:29 -04:00
upload/pack.sh gcp "${RAW_IMAGE_PATH}" "${GCP_IMAGE_PATH}"
bazel run //image/upload -- image gcp \
2023-04-27 05:37:37 -04:00
--verbose \
--raw-image "${GCP_IMAGE_PATH}" \
2023-05-23 10:22:29 -04:00
--attestation-variant "${ATTESTATION_VARIANT}" \
2023-04-27 05:37:37 -04:00
--version "${SHORTNAME}" \
2023-05-23 10:22:29 -04:00
--out "${JSON_OUTPUT}"
echo -e "Uploaded GCP image: \n\n\`\`\`\n$(jq < "${JSON_OUTPUT}")\n\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
2023-01-18 04:15:58 -05:00
echo "::endgroup::"
2022-10-19 07:10:15 -04:00
- name : Upload Azure image
2023-01-18 04:15:58 -05:00
if : matrix.csp == 'azure'
2022-10-19 07:10:15 -04:00
shell : bash
2022-10-21 04:11:53 -04:00
working-directory : ${{ github.workspace }}/image
2023-01-18 04:15:58 -05:00
run : |
echo "::group::Upload Azure image"
2023-05-23 10:22:29 -04:00
upload/pack.sh azure "${RAW_IMAGE_PATH}" "${AZURE_IMAGE_PATH}"
bazel run //image/upload -- image azure \
2023-04-27 05:37:37 -04:00
--verbose \
--raw-image "${AZURE_IMAGE_PATH}" \
2023-05-23 10:22:29 -04:00
--attestation-variant "${ATTESTATION_VARIANT}" \
2023-04-27 05:37:37 -04:00
--version "${SHORTNAME}" \
2023-05-23 10:22:29 -04:00
--out "${JSON_OUTPUT}"
echo -e "Uploaded Azure image: \n\n\`\`\`\n$(jq < "${JSON_OUTPUT}")\n\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
2023-01-18 04:15:58 -05:00
echo "::endgroup::"
2022-10-19 07:10:15 -04:00
2023-02-27 12:19:52 -05:00
- name : Upload OpenStack image
if : matrix.csp == 'openstack'
shell : bash
working-directory : ${{ github.workspace }}/image
run : |
echo "::group::Upload OpenStack image"
2023-05-23 10:22:29 -04:00
bazel run //image/upload -- image openstack \
2023-04-27 05:37:37 -04:00
--verbose \
2023-05-23 10:22:29 -04:00
--raw-image "${RAW_IMAGE_PATH}" \
--attestation-variant "${ATTESTATION_VARIANT}" \
2023-04-27 05:37:37 -04:00
--version "${SHORTNAME}" \
2023-05-23 10:22:29 -04:00
--out "${JSON_OUTPUT}"
echo -e "Uploaded OpenStack image: \n\n\`\`\`\n$(jq < "${JSON_OUTPUT}")\n\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
2023-02-27 12:19:52 -05:00
echo "::endgroup::"
2022-11-16 09:45:10 -05:00
- name : Upload QEMU image
2022-12-09 05:51:38 -05:00
if : matrix.csp == 'qemu'
2023-01-18 04:15:58 -05:00
shell : bash
2022-11-16 09:45:10 -05:00
working-directory : ${{ github.workspace }}/image
2023-01-18 04:15:58 -05:00
run : |
echo "::group::Upload QEMU image"
2023-05-23 10:22:29 -04:00
bazel run //image/upload -- image qemu \
2023-04-27 05:37:37 -04:00
--verbose \
2023-05-23 10:22:29 -04:00
--raw-image "${RAW_IMAGE_PATH}" \
--attestation-variant "${ATTESTATION_VARIANT}" \
2023-04-27 05:37:37 -04:00
--version "${SHORTNAME}" \
2023-05-23 10:22:29 -04:00
--out "${JSON_OUTPUT}"
echo -e "Uploaded QEMU image: \n\n\`\`\`\n$(jq < "${JSON_OUTPUT}")\n\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
2023-01-18 04:15:58 -05:00
echo "::endgroup::"
2022-11-16 09:45:10 -05:00
- name : Upload image lookup table as artifact
2023-01-06 11:35:54 -05:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
2022-11-16 09:45:10 -05:00
with :
name : lookup-table
path : ${{ github.workspace }}/image/mkosi.output.*/*/image-upload*.json
2022-10-18 10:23:00 -04:00
calculate-pcrs :
name : "Calculate PCRs"
2022-11-16 09:45:10 -05:00
needs : [ build-settings, make-os-image]
permissions :
id-token : write
contents : read
2022-10-18 10:23:00 -04:00
runs-on : ubuntu-22.04
strategy :
2022-11-03 10:22:51 -04:00
fail-fast : false
2022-10-18 10:23:00 -04:00
matrix :
2023-05-23 10:22:29 -04:00
include :
- csp : aws
attestation_variant : aws-nitro-tpm
2023-05-26 04:15:30 -04:00
- csp : aws
attestation_variant : aws-sev-snp
2023-05-23 10:22:29 -04:00
- csp : azure
attestation_variant : azure-sev-snp
- csp : gcp
attestation_variant : gcp-sev-es
- csp : gcp
attestation_variant : gcp-sev-snp
- csp : qemu
attestation_variant : qemu-vtpm
- csp : openstack
attestation_variant : qemu-vtpm
2022-10-18 10:23:00 -04:00
steps :
- name : Checkout repository
2023-05-05 08:42:20 -04:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2022-11-10 11:22:26 -05:00
with :
2023-01-02 06:25:17 -05:00
ref : ${{ inputs.ref || github.head_ref }}
2022-10-18 10:23:00 -04:00
- name : Download OS image artifact
2023-01-06 11:35:54 -05:00
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
2022-10-18 10:23:00 -04:00
with :
2023-05-23 10:22:29 -04:00
name : image-${{ matrix.csp }}-${{ matrix.attestation_variant }}
2022-10-18 10:23:00 -04:00
- name : Install dependencies
run : |
echo "::group::Install dependencies"
2023-01-17 10:12:23 -05:00
python -m pip install --user --require-hashes -r .github/workflows/build-os-image-requirements.txt
2022-10-18 10:23:00 -04:00
sudo apt-get update
sudo apt-get install -y systemd-container # for systemd-dissect
echo "::endgroup::"
- name : Calculate expected PCRs
2023-01-18 04:15:58 -05:00
working-directory : ${{ github.workspace }}/image/measured-boot
2022-10-18 10:23:00 -04:00
run : |
echo "::group::Calculate expected PCRs"
2022-11-11 08:49:16 -05:00
{
2023-05-23 10:22:29 -04:00
./precalculate_pcr_4.sh ${{ github.workspace }}/image.raw ${{ github.workspace }}/pcr-4-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json
./precalculate_pcr_9.sh ${{ github.workspace }}/image.raw ${{ github.workspace }}/pcr-9-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json
./precalculate_pcr_12.sh ${{ github.workspace }}/image.raw ${{ github.workspace }}/pcr-12-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json ${{ matrix.csp }}
2022-11-11 08:49:16 -05:00
} >> "$GITHUB_STEP_SUMMARY"
2022-10-13 04:53:52 -04:00
cp pcr-stable.json ${{ github.workspace }}/
2023-05-23 10:22:29 -04:00
jq -sSc '.[0] * .[1] * .[2] * .[3]' ${{ github.workspace }}/pcr-* > ${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json
2022-10-18 10:23:00 -04:00
echo "::endgroup::"
2023-02-09 07:33:17 -05:00
- name : Add static PCRs
run : |
case ${{ matrix.csp }} in
aws)
yq e '.csp = "AWS" |
2023-05-23 10:22:29 -04:00
.attestationVariant = "${{ matrix.attestation_variant }}" |
2023-02-09 07:33:17 -05:00
.measurements.0.warnOnly = true |
.measurements.0.expected = "737f767a12f54e70eecbc8684011323ae2fe2dd9f90785577969d7a2013e8c12" |
.measurements.2.warnOnly = true |
.measurements.2.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.3.warnOnly = true |
.measurements.3.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.4.warnOnly = false |
.measurements.6.warnOnly = true |
.measurements.6.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.7.warnOnly = true |
.measurements.7.expected = "120e498db2a224bd512b6efc9b0234f843e10bf061eb7a76ecca5509a2238901" |
.measurements.8.warnOnly = false |
.measurements.9.warnOnly = false |
.measurements.11.warnOnly = false |
.measurements.12.warnOnly = false |
.measurements.13.warnOnly = false |
.measurements.14.warnOnly = true |
.measurements.14.expected = "d7c4cc7ff7933022f013e03bdee875b91720b5b86cf1753cad830f95e791926f" |
.measurements.15.warnOnly = false' \
2023-05-23 10:22:29 -04:00
-I 0 -o json -i "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json"
2023-02-09 07:33:17 -05:00
;;
azure)
yq e '.csp = "Azure" |
2023-05-23 10:22:29 -04:00
.attestationVariant = "${{ matrix.attestation_variant }}" |
2023-02-09 07:33:17 -05:00
.measurements.1.warnOnly = true |
.measurements.1.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.2.warnOnly = true |
.measurements.2.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.3.warnOnly = true |
.measurements.3.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.4.warnOnly = false |
.measurements.7.warnOnly = true |
.measurements.7.expected = "346547a8ce5957af27e552427d6b9e6d9cb502f0156e9155380451eea1b3f0ed" |
.measurements.8.warnOnly = false |
.measurements.9.warnOnly = false |
.measurements.11.warnOnly = false |
.measurements.12.warnOnly = false |
.measurements.13.warnOnly = false |
.measurements.14.warnOnly = true |
.measurements.14.expected = "d7c4cc7ff7933022f013e03bdee875b91720b5b86cf1753cad830f95e791926f" |
.measurements.15.warnOnly = false' \
2023-05-23 10:22:29 -04:00
-I 0 -o json -i "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json"
2023-02-09 07:33:17 -05:00
;;
gcp)
yq e '.csp = "GCP" |
2023-05-23 10:22:29 -04:00
.attestationVariant = "${{ matrix.attestation_variant }}" |
2023-02-09 07:33:17 -05:00
.measurements.1.warnOnly = true |
.measurements.1.expected = "745f2fb4235e4647aa0ad5ace781cd929eb68c28870e7dd5d1a1535854325e56" |
.measurements.2.warnOnly = true |
.measurements.2.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.3.warnOnly = true |
.measurements.3.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.4.warnOnly = false |
.measurements.6.warnOnly = true |
.measurements.6.expected = "3d458cfe55cc03ea1f443f1562beec8df51c75e14a9fcf9a7234a13f198e7969" |
.measurements.7.warnOnly = true |
.measurements.7.expected = "b1e9b305325c51b93da58cbf7f92512d8eebfa01143e4d8844e40e062e9b6cd5" |
.measurements.8.warnOnly = false |
.measurements.9.warnOnly = false |
.measurements.11.warnOnly = false |
.measurements.12.warnOnly = false |
.measurements.13.warnOnly = false |
.measurements.14.warnOnly = true |
.measurements.14.expected = "d7c4cc7ff7933022f013e03bdee875b91720b5b86cf1753cad830f95e791926f" |
.measurements.15.warnOnly = false' \
2023-05-23 10:22:29 -04:00
-I 0 -o json -i "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json"
2023-02-09 07:33:17 -05:00
;;
2023-02-27 12:19:52 -05:00
openstack)
yq e '.csp = "OpenStack" |
2023-05-23 10:22:29 -04:00
.attestationVariant = "${{ matrix.attestation_variant }}" |
2023-02-27 12:19:52 -05:00
.measurements.4.warnOnly = false |
.measurements.8.warnOnly = false |
.measurements.9.warnOnly = false |
.measurements.11.warnOnly = false |
.measurements.12.warnOnly = false |
.measurements.13.warnOnly = false |
.measurements.15.warnOnly = false' \
2023-05-23 10:22:29 -04:00
-I 0 -o json -i "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json"
2023-02-27 12:19:52 -05:00
;;
2023-02-09 07:33:17 -05:00
qemu)
yq e '.csp = "QEMU" |
2023-05-23 10:22:29 -04:00
.attestationVariant = "${{ matrix.attestation_variant }}" |
2023-02-09 07:33:17 -05:00
.measurements.4.warnOnly = false |
.measurements.8.warnOnly = false |
.measurements.9.warnOnly = false |
.measurements.11.warnOnly = false |
.measurements.12.warnOnly = false |
.measurements.13.warnOnly = false |
.measurements.15.warnOnly = false' \
2023-05-23 10:22:29 -04:00
-I 0 -o json -i "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json"
2023-02-09 07:33:17 -05:00
;;
*)
echo "Unknown CSP: ${{ matrix.csp }}"
exit 1
;;
esac
2023-05-23 10:22:29 -04:00
- name : Envelope measurements
shell : bash
run : |
echo "::group::Envelope measurements"
bazel run //image/upload -- measurements envelope \
--in "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json" \
--out "${{ github.workspace }}/pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json" \
--version "${{ needs.build-settings.outputs.imageNameShort }}" \
--csp "${{ matrix.csp }}" \
--attestation-variant "${{ matrix.attestation_variant }}"
echo "::endgroup::"
- name : Upload expected measurements as artifact
2023-01-06 11:35:54 -05:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
2022-10-18 10:23:00 -04:00
with :
2023-05-23 10:22:29 -04:00
name : measurements
path : pcrs-${{ matrix.csp }}-${{ matrix.attestation_variant }}.json
upload-pcrs :
name : "Sign & upload PCRs"
needs : [ build-settings, calculate-pcrs]
permissions :
id-token : write
contents : read
runs-on : ubuntu-22.04
steps :
- name : Checkout repository
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with :
ref : ${{ inputs.ref || github.head_ref }}
- name : Download measurements
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with :
name : measurements
- name : Login to AWS
uses : aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with :
role-to-assume : arn:aws:iam::795746500882:role/GitHubConstellationImagePipeline
aws-region : eu-central-1
2022-10-18 10:23:00 -04:00
2023-02-09 07:33:17 -05:00
- name : Install Cosign
uses : sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b # tag=v2.8.1
- name : Install Rekor
shell : bash
run : |
curl -fsSLO https://github.com/sigstore/rekor/releases/download/v0.12.0/rekor-cli-linux-amd64
sudo install rekor-cli-linux-amd64 /usr/local/bin/rekor-cli
rm rekor-cli-linux-amd64
2023-05-23 10:22:29 -04:00
- name : Merge measurements
shell : bash
run : |
echo "::group::Merge measurements"
bazel run //image/upload -- measurements merge \
--out measurements.json \
pcrs-*.json
echo "::endgroup::"
2023-02-09 07:33:17 -05:00
- name : Sign measurements
2023-06-06 04:32:22 -04:00
if : inputs.stream != 'debug'
2023-02-09 07:33:17 -05:00
shell : bash
env :
COSIGN_PUBLIC_KEY : ${{ inputs.isRelease && secrets.COSIGN_PUBLIC_KEY || secrets.COSIGN_DEV_PUBLIC_KEY }}
COSIGN_PRIVATE_KEY : ${{ inputs.isRelease && secrets.COSIGN_PRIVATE_KEY || secrets.COSIGN_DEV_PRIVATE_KEY }}
COSIGN_PASSWORD : ${{ inputs.isRelease && secrets.COSIGN_PASSWORD || secrets.COSIGN_DEV_PASSWORD }}
run : |
echo "${COSIGN_PUBLIC_KEY}" > cosign.pub
# Enabling experimental mode also publishes signature to Rekor
COSIGN_EXPERIMENTAL=1 cosign sign-blob --key env://COSIGN_PRIVATE_KEY \
2023-05-23 10:22:29 -04:00
"${{ github.workspace }}/measurements.json" > "${{ github.workspace }}/measurements.json.sig"
2023-02-09 07:33:17 -05:00
# Verify - As documentation & check
# Local Signature (input: artifact, key, signature)
cosign verify-blob --key cosign.pub \
2023-05-23 10:22:29 -04:00
--signature "measurements.json.sig" \
"measurements.json"
2023-02-09 07:33:17 -05:00
# Transparency Log Signature (input: artifact, key)
2023-05-23 10:22:29 -04:00
uuid=$(rekor-cli search --artifact "${{ github.workspace }}/measurements.json" | tail -n 1)
2023-02-09 07:33:17 -05:00
sig=$(rekor-cli get --uuid="${uuid}" --format=json | jq -r .Body.HashedRekordObj.signature.content)
2023-05-23 10:22:29 -04:00
cosign verify-blob --key cosign.pub --signature <(echo "${sig}") "${{ github.workspace }}/measurements.json"
2023-02-09 07:33:17 -05:00
2023-06-06 04:32:22 -04:00
- name : Create stub signature file
if : inputs.stream == 'debug'
shell : bash
run : |
echo "THOSE MEASUREMENTS BELONG TO A DEBUG IMAGE. THOSE ARE NOT SINGED BY ANY KEY." > "${{ github.workspace }}/measurements.json.sig"
2023-05-23 10:22:29 -04:00
- name : Upload measurements
2022-11-16 09:45:10 -05:00
shell : bash
run : |
2023-05-23 10:22:29 -04:00
echo "::group::Upload measurements"
bazel run //image/upload -- measurements upload \
--measurements measurements.json \
--signature measurements.json.sig
echo "::endgroup::"
2022-11-16 09:45:10 -05:00
2022-10-19 07:10:15 -04:00
generate-sbom :
name : "Generate SBOM"
2022-11-16 09:45:10 -05:00
needs : [ build-settings, build-dependencies, make-os-image]
permissions :
id-token : write
contents : read
2022-10-19 07:10:15 -04:00
runs-on : ubuntu-22.04
steps :
2022-11-16 09:45:10 -05:00
- name : Login to AWS
2023-03-21 05:56:30 -04:00
uses : aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
2022-11-16 09:45:10 -05:00
with :
role-to-assume : arn:aws:iam::795746500882:role/GitHubConstellationImagePipeline
aws-region : eu-central-1
2022-10-19 07:10:15 -04:00
- name : Install squashfs tools
run : |
echo "::group::Install squashfs tools"
sudo apt-get update
sudo apt-get install -y squashfs-tools
echo "::endgroup::"
- name : Download rootfs
2023-01-06 11:35:54 -05:00
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
2022-10-19 07:10:15 -04:00
with :
# downloading / using only the QEMU rootfs is fine
# since the images only differ in the ESP partition
2023-05-23 10:22:29 -04:00
name : parts-qemu-qemu-vtpm
2022-10-19 07:10:15 -04:00
2022-11-16 09:45:10 -05:00
- name : Download manifest
2023-01-06 11:35:54 -05:00
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
2022-11-16 09:45:10 -05:00
with :
# downloading / using only the QEMU manifest is fine
# since the images only differ in the ESP partition
2023-05-23 10:22:29 -04:00
name : manifest-qemu-qemu-vtpm
2022-11-16 09:45:10 -05:00
2022-10-19 07:10:15 -04:00
- name : Unpack squashfs
run : |
echo "::group::Unpack squashfs"
2023-04-25 12:22:40 -04:00
unsquashfs -user-xattrs -d image.root.tree image.root-x86-64.raw
2022-10-19 07:10:15 -04:00
echo "::endgroup::"
2023-01-18 04:15:58 -05:00
- name : Create SBOM in SPDX fromat
2023-04-03 10:36:43 -04:00
uses : anchore/sbom-action@422cb34a0f8b599678c41b21163ea6088edb2624 # v0.14.1
2022-10-19 07:10:15 -04:00
with :
path : image.root.tree
artifact-name : sbom.spdx.json
2022-11-16 09:45:10 -05:00
output-file : sbom.spdx.json
2022-10-19 07:10:15 -04:00
format : spdx-json
2023-01-18 04:15:58 -05:00
- name : Create SBOM in CycloneDX fromat
2023-04-03 10:36:43 -04:00
uses : anchore/sbom-action@422cb34a0f8b599678c41b21163ea6088edb2624 # v0.14.1
2022-10-19 07:10:15 -04:00
with :
path : image.root.tree
artifact-name : sbom.cyclonedx.json
2022-11-16 09:45:10 -05:00
output-file : sbom.cyclonedx.json
2022-10-19 07:10:15 -04:00
format : cyclonedx-json
2023-01-18 04:15:58 -05:00
- name : Create SBOM in Syft fromat
2023-04-03 10:36:43 -04:00
uses : anchore/sbom-action@422cb34a0f8b599678c41b21163ea6088edb2624 # v0.14.1
2022-10-19 07:10:15 -04:00
with :
path : image.root.tree
artifact-name : sbom.syft.json
2022-11-16 09:45:10 -05:00
output-file : sbom.syft.json
2022-10-19 07:10:15 -04:00
format : syft-json
2022-10-01 18:48:06 -04:00
- name : Combine hashes
run : |
cat > SHA256SUMS <<EOF
${{ needs.build-dependencies.outputs.bootstrapper-sha256 }} bootstrapper
${{ needs.build-dependencies.outputs.disk-mapper-sha256 }} disk-mapper
2022-12-29 11:50:11 -05:00
${{ needs.build-dependencies.outputs.upgrade-agent-sha256 }} upgrade-agent
2023-03-09 09:01:09 -05:00
${{ needs.build-dependencies.outputs.measurement-reader-sha256 }} measurement-reader
2023-05-23 10:22:29 -04:00
${{ needs.make-os-image.outputs.image-raw-aws-aws-nitro-tpm-sha256 }} aws/image.raw
${{ needs.make-os-image.outputs.image-raw-changelog-aws-aws-nitro-tpm-sha256 }} aws/image.changelog
${{ needs.make-os-image.outputs.image-raw-manifest-aws-aws-nitro-tpm-sha256 }} aws/image.manifest
${{ needs.make-os-image.outputs.image-efi-aws-aws-nitro-tpm-sha256 }} aws/image.efi
${{ needs.make-os-image.outputs.image-initrd-aws-aws-nitro-tpm-sha256 }} aws/image.initrd
${{ needs.make-os-image.outputs.image-root-raw-aws-aws-nitro-tpm-sha256 }} aws/image.root-x86-64.raw
${{ needs.make-os-image.outputs.image-root-verity-aws-aws-nitro-tpm-sha256 }} aws/image.root.verity
${{ needs.make-os-image.outputs.image-vmlinuz-aws-aws-nitro-tpm-sha256 }} aws/image.vmlinuz
${{ needs.make-os-image.outputs.image-raw-azure-azure-sev-snp-sha256 }} azure/image.raw
${{ needs.make-os-image.outputs.image-raw-changelog-azure-azure-sev-snp-sha256 }} azure/image.changelog
${{ needs.make-os-image.outputs.image-raw-manifest-azure-azure-sev-snp-sha256 }} azure/image.manifest
${{ needs.make-os-image.outputs.image-efi-azure-azure-sev-snp-sha256 }} azure/image.efi
${{ needs.make-os-image.outputs.image-initrd-azure-azure-sev-snp-sha256 }} azure/image.initrd
${{ needs.make-os-image.outputs.image-root-raw-azure-azure-sev-snp-sha256 }} azure/image.root-x86-64.raw
${{ needs.make-os-image.outputs.image-root-verity-azure-azure-sev-snp-sha256 }} azure/image.root.verity
${{ needs.make-os-image.outputs.image-vmlinuz-azure-azure-sev-snp-sha256 }} azure/image.vmlinuz
${{ needs.make-os-image.outputs.image-raw-gcp-gcp-sev-es-sha256 }} gcp/image.raw
${{ needs.make-os-image.outputs.image-raw-changelog-gcp-gcp-sev-es-sha256 }} gcp/image.changelog
${{ needs.make-os-image.outputs.image-raw-manifest-gcp-gcp-sev-es-sha256 }} gcp/image.manifest
${{ needs.make-os-image.outputs.image-efi-gcp-gcp-sev-es-sha256 }} gcp/image.efi
${{ needs.make-os-image.outputs.image-initrd-gcp-gcp-sev-es-sha256 }} gcp/image.initrd
${{ needs.make-os-image.outputs.image-root-raw-gcp-gcp-sev-es-sha256 }} gcp/image.root-x86-64.raw
${{ needs.make-os-image.outputs.image-root-verity-gcp-gcp-sev-es-sha256 }} gcp/image.root.verity
${{ needs.make-os-image.outputs.image-vmlinuz-gcp-gcp-sev-es-sha256 }} gcp/image.vmlinuz
${{ needs.make-os-image.outputs.image-raw-qemu-qemu-vtpm-sha256 }} qemu/image.raw
${{ needs.make-os-image.outputs.image-raw-changelog-qemu-qemu-vtpm-sha256 }} qemu/image.changelog
${{ needs.make-os-image.outputs.image-raw-manifest-qemu-qemu-vtpm-sha256 }} qemu/image.manifest
${{ needs.make-os-image.outputs.image-efi-qemu-qemu-vtpm-sha256 }} qemu/image.efi
${{ needs.make-os-image.outputs.image-initrd-qemu-qemu-vtpm-sha256 }} qemu/image.initrd
${{ needs.make-os-image.outputs.image-root-raw-qemu-qemu-vtpm-sha256 }} qemu/image.root-x86-64.raw
${{ needs.make-os-image.outputs.image-root-verity-qemu-qemu-vtpm-sha256 }} qemu/image.root.verity
${{ needs.make-os-image.outputs.image-vmlinuz-qemu-qemu-vtpm-sha256 }} qemu/image.vmlinuz
2022-10-01 18:48:06 -04:00
EOF
cat SHA256SUMS
2022-11-11 08:49:16 -05:00
echo -e "SHA256SUMS:\n\`\`\`\n$(cat SHA256SUMS)\n\`\`\`" >> "$GITHUB_STEP_SUMMARY"
2022-11-16 09:45:10 -05:00
- name : Upload SBOMs to S3
shell : bash
run : |
sboms='sbom.spdx.json sbom.cyclonedx.json sbom.syft.json'
2023-04-25 12:22:40 -04:00
manifests='image.manifest image.changelog'
2022-11-16 09:45:10 -05:00
hashes='SHA256SUMS'
for file in ${sboms} ${manifests} ${hashes}; do
aws s3 cp \
"${file}" \
2022-12-09 05:51:38 -05:00
"s3://cdn-constellation-backend/${{needs.build-settings.outputs.imageApiBasePath}}/${file}" \
2022-11-16 09:45:10 -05:00
--no -progress
done
2023-02-24 06:00:04 -05:00
upload-artifacts :
name : "Upload image lookup table and CLI compatibility info"
2022-11-16 09:45:10 -05:00
runs-on : ubuntu-22.04
needs : [ build-settings, upload-os-image]
permissions :
id-token : write
contents : read
steps :
2023-05-23 10:22:29 -04:00
- name : Checkout repository
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with :
ref : ${{ inputs.ref || github.head_ref }}
2022-11-16 09:45:10 -05:00
- name : Download image lookup table
2023-01-06 11:35:54 -05:00
uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3
2022-11-16 09:45:10 -05:00
with :
name : lookup-table
2022-12-09 05:51:38 -05:00
- name : Login to AWS
2023-03-21 05:56:30 -04:00
uses : aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
2022-12-09 05:51:38 -05:00
with :
role-to-assume : arn:aws:iam::795746500882:role/GitHubConstellationImagePipeline
aws-region : eu-central-1
2022-11-16 09:45:10 -05:00
- name : Upload lookup table to S3
shell : bash
2023-05-23 10:22:29 -04:00
run : bazel run //image/upload -- info --verbose mkosi.output.*/*/image-upload*.json
2022-12-09 05:51:38 -05:00
2023-02-24 06:00:04 -05:00
- name : Checkout
2023-05-05 08:42:20 -04:00
uses : actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
2023-02-24 06:00:04 -05:00
with :
ref : ${{ inputs.ref || github.head_ref }}
- name : Setup Go environment
2023-04-04 05:06:30 -04:00
uses : actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
2023-02-24 06:00:04 -05:00
with :
2023-05-11 08:14:15 -04:00
go-version : "1.20.4"
2023-02-24 06:00:04 -05:00
cache : true
- name : Create CLI compatibility information artifact
shell : bash
run : |
go run ./hack/cli-k8s-compatibility/main.go \
--ref=${{ needs.build-settings.outputs.ref }} \
--stream=${{ needs.build-settings.outputs.stream }} \
--version=${{ needs.build-settings.outputs.imageVersion }} \
2023-03-10 04:21:58 -05:00
add-image-version-to-versionsapi :
2023-02-24 06:00:04 -05:00
needs : [ upload-artifacts, build-settings]
2023-03-10 04:21:58 -05:00
name : "Add image version to versionsapi"
2023-01-04 11:07:16 -05:00
if : needs.build-settings.outputs.ref != '-'
2023-01-30 10:11:27 -05:00
permissions :
contents : read
id-token : write
2023-01-04 11:07:16 -05:00
uses : ./.github/workflows/versionsapi.yml
with :
command : add
ref : ${{ needs.build-settings.outputs.ref }}
2023-01-16 07:56:06 -05:00
stream : ${{ needs.build-settings.outputs.stream }}
2023-01-04 11:07:16 -05:00
version : ${{ needs.build-settings.outputs.imageVersion }}
2023-03-10 04:21:58 -05:00
kind : "image"
add_latest : true
add-cli-version-to-versionsapi :
2023-04-13 11:44:23 -04:00
needs : [ upload-artifacts, build-settings, add-image-version-to-versionsapi]
2023-03-10 04:21:58 -05:00
name : "Add CLI version to versionsapi"
if : needs.build-settings.outputs.ref != '-'
permissions :
contents : read
id-token : write
uses : ./.github/workflows/versionsapi.yml
with :
command : add
ref : ${{ needs.build-settings.outputs.ref }}
stream : ${{ needs.build-settings.outputs.stream }}
version : ${{ needs.build-settings.outputs.imageVersion }}
kind : "cli"
2023-01-04 11:07:16 -05:00
add_latest : true