2024-01-09 13:37:56 -05:00
|
|
|
# Verify that Constellation builds are reproducible.
|
|
|
|
#
|
|
|
|
# The build-* jobs' matrix has two dimensions: a list of targets to build and
|
|
|
|
# a list of runners to build on. The produced binaries and OS images are
|
|
|
|
# expected to be bit-for-bit identical, regardless of the chosen build runner.
|
|
|
|
#
|
|
|
|
# The compare-* jobs only have the target dimension. They obtain the built
|
|
|
|
# targets from all runners and check that there are no diffs between them.
|
2023-06-23 06:12:32 -04:00
|
|
|
name: Reproducible Builds
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
|
|
- cron: "45 06 * * 1" # Every Monday at 6:45am
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-binaries:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- "cli_enterprise_darwin_amd64"
|
|
|
|
- "cli_enterprise_darwin_arm64"
|
|
|
|
- "cli_enterprise_linux_amd64"
|
|
|
|
- "cli_enterprise_linux_arm64"
|
|
|
|
- "cli_enterprise_windows_amd64"
|
2023-12-11 02:59:19 -05:00
|
|
|
runner: ["ubuntu-22.04", "ubuntu-20.04"]
|
2023-06-23 06:12:32 -04:00
|
|
|
env:
|
|
|
|
bazel_target: "//cli:${{ matrix.target }}"
|
|
|
|
binary: "${{ matrix.target }}-${{ matrix.runner }}"
|
|
|
|
runs-on: ${{ matrix.runner }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-05-24 05:04:23 -04:00
|
|
|
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
2023-06-23 06:12:32 -04:00
|
|
|
with:
|
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
|
|
|
|
|
|
|
- name: Setup bazel
|
2023-10-04 07:55:38 -04:00
|
|
|
uses: ./.github/actions/setup_bazel_nix
|
2023-06-23 06:12:32 -04:00
|
|
|
|
|
|
|
- name: Build
|
|
|
|
shell: bash
|
|
|
|
run: bazel build "${bazel_target}"
|
|
|
|
|
|
|
|
- name: Copy
|
|
|
|
shell: bash
|
|
|
|
run: cp "$(bazel cquery --output=files "${bazel_target}")" "${binary}"
|
|
|
|
|
|
|
|
- name: Collect hash (linux)
|
|
|
|
shell: bash
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: sha256sum "${binary}" | tee "${binary}.sha256"
|
|
|
|
|
|
|
|
- name: Collect hash (macOS)
|
|
|
|
shell: bash
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: shasum -a 256 "${binary}" | tee "${binary}.sha256"
|
|
|
|
|
|
|
|
- name: Upload binary artifact
|
2024-05-08 08:33:35 -04:00
|
|
|
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
2023-06-23 06:12:32 -04:00
|
|
|
with:
|
2024-01-05 10:57:21 -05:00
|
|
|
name: "binaries-${{ matrix.target }}-${{ matrix.runner }}"
|
2023-06-23 06:12:32 -04:00
|
|
|
path: "${{ env.binary }}"
|
|
|
|
|
|
|
|
- name: Upload hash artifact
|
2024-05-08 08:33:35 -04:00
|
|
|
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
2023-06-23 06:12:32 -04:00
|
|
|
with:
|
2024-01-05 10:57:21 -05:00
|
|
|
name: "sha256sums-${{ matrix.target }}-${{ matrix.runner }}"
|
2023-06-23 06:12:32 -04:00
|
|
|
path: "${{ env.binary }}.sha256"
|
|
|
|
|
2023-12-11 03:28:25 -05:00
|
|
|
build-osimages:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- "azure_azure-sev-snp_stable"
|
|
|
|
- "aws_aws-nitro-tpm_console"
|
|
|
|
- "qemu_qemu-vtpm_debug"
|
|
|
|
- "gcp_gcp-sev-snp_nightly"
|
|
|
|
runner: ["ubuntu-22.04", "ubuntu-20.04"]
|
|
|
|
env:
|
|
|
|
bazel_target: "//image/system:${{ matrix.target }}"
|
|
|
|
binary: "osimage-${{ matrix.target }}-${{ matrix.runner }}"
|
|
|
|
runs-on: ${{ matrix.runner }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-05-24 05:04:23 -04:00
|
|
|
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
2023-12-11 03:28:25 -05:00
|
|
|
with:
|
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
|
|
|
|
|
|
|
- name: Setup bazel
|
|
|
|
uses: ./.github/actions/setup_bazel_nix
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
shell: bash
|
|
|
|
run: bazel build "${bazel_target}"
|
|
|
|
|
|
|
|
- name: Copy
|
|
|
|
shell: bash
|
|
|
|
run: cp "$(bazel cquery --output=files "${bazel_target}")/constellation.raw" "${binary}"
|
|
|
|
|
|
|
|
- name: Collect hash (linux)
|
|
|
|
shell: bash
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: sha256sum "${binary}" | tee "${binary}.sha256"
|
|
|
|
|
|
|
|
- name: Collect hash (macOS)
|
|
|
|
shell: bash
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: shasum -a 256 "${binary}" | tee "${binary}.sha256"
|
|
|
|
|
|
|
|
- name: Upload binary artifact
|
2024-05-08 08:33:35 -04:00
|
|
|
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
2023-12-11 03:28:25 -05:00
|
|
|
with:
|
2024-01-05 10:57:21 -05:00
|
|
|
name: "osimages-${{ matrix.target }}-${{ matrix.runner }}"
|
2023-12-11 03:28:25 -05:00
|
|
|
path: "${{ env.binary }}"
|
|
|
|
|
|
|
|
- name: Upload hash artifact
|
2024-05-08 08:33:35 -04:00
|
|
|
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
|
2023-12-11 03:28:25 -05:00
|
|
|
with:
|
2024-01-05 10:57:21 -05:00
|
|
|
name: "sha256sums-${{ matrix.target }}-${{ matrix.runner }}"
|
2023-12-11 03:28:25 -05:00
|
|
|
path: "${{ env.binary }}.sha256"
|
|
|
|
|
|
|
|
compare-binaries:
|
2023-06-23 06:12:32 -04:00
|
|
|
needs: build-binaries
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- "cli_enterprise_darwin_amd64"
|
|
|
|
- "cli_enterprise_darwin_arm64"
|
|
|
|
- "cli_enterprise_linux_amd64"
|
|
|
|
- "cli_enterprise_linux_arm64"
|
|
|
|
- "cli_enterprise_windows_amd64"
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
2024-05-24 05:04:23 -04:00
|
|
|
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
2023-12-21 13:28:18 -05:00
|
|
|
with:
|
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
|
|
|
|
|
|
|
- name: Download binaries
|
2024-05-08 08:33:35 -04:00
|
|
|
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
|
2023-12-21 13:28:18 -05:00
|
|
|
with:
|
2024-01-05 10:57:21 -05:00
|
|
|
pattern: "binaries-${{ matrix.target }}-*"
|
|
|
|
merge-multiple: true
|
2023-12-21 13:28:18 -05:00
|
|
|
|
|
|
|
- name: Hash
|
|
|
|
shell: bash
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: sha256sum cli_enterprise*
|
|
|
|
|
|
|
|
- name: Compare binaries
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
# shellcheck disable=SC2207,SC2116
|
|
|
|
list=($(echo "cli_enterprise*"))
|
|
|
|
diff -s --to-file="${list[0]}" "${list[@]:1}" | tee "${GITHUB_STEP_SUMMARY}"
|
2023-12-11 03:28:25 -05:00
|
|
|
|
|
|
|
compare-osimages:
|
|
|
|
needs: build-osimages
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- "azure_azure-sev-snp_stable"
|
|
|
|
- "aws_aws-nitro-tpm_console"
|
|
|
|
- "qemu_qemu-vtpm_debug"
|
|
|
|
- "gcp_gcp-sev-snp_nightly"
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
2024-05-24 05:04:23 -04:00
|
|
|
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
2023-12-21 13:28:18 -05:00
|
|
|
with:
|
|
|
|
ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }}
|
|
|
|
|
|
|
|
- name: Download os images
|
2024-05-08 08:33:35 -04:00
|
|
|
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
|
2023-12-21 13:28:18 -05:00
|
|
|
with:
|
2024-01-05 10:57:21 -05:00
|
|
|
pattern: "osimages-${{ matrix.target }}-*"
|
|
|
|
merge-multiple: true
|
2023-12-21 13:28:18 -05:00
|
|
|
|
|
|
|
- name: Hash
|
|
|
|
shell: bash
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: sha256sum osimage-*
|
|
|
|
|
|
|
|
- name: Compare os images
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
# shellcheck disable=SC2207,SC2116
|
|
|
|
list=($(echo "osimage-*"))
|
|
|
|
diff -s --to-file="${list[0]}" "${list[@]:1}" | tee "${GITHUB_STEP_SUMMARY}"
|