2022-05-03 05:15:53 -04:00
|
|
|
name: build
|
2022-07-04 06:16:11 -04:00
|
|
|
description: |
|
|
|
|
Runs cmake & default make target in build folder. Additionally, Sigstore tools
|
|
|
|
are used to sign CLI and publish a release when run on v* tag.
|
|
|
|
inputs:
|
|
|
|
cosign-public-key:
|
|
|
|
description: 'Cosign public key'
|
2022-07-07 06:18:41 -04:00
|
|
|
required: false
|
|
|
|
default: ''
|
2022-07-04 06:16:11 -04:00
|
|
|
cosign-private-key:
|
|
|
|
description: 'Cosign private key'
|
2022-07-07 06:18:41 -04:00
|
|
|
required: false
|
|
|
|
default: ''
|
2022-07-04 06:16:11 -04:00
|
|
|
cosign-password:
|
|
|
|
description: 'Password for Cosign private key'
|
2022-07-07 06:18:41 -04:00
|
|
|
required: false
|
|
|
|
default: ''
|
2022-05-03 05:15:53 -04:00
|
|
|
runs:
|
2022-06-30 05:27:23 -04:00
|
|
|
using: "composite"
|
2022-05-03 05:15:53 -04:00
|
|
|
steps:
|
2022-06-30 05:27:23 -04:00
|
|
|
- name: Install build dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install \
|
|
|
|
build-essential cmake \
|
|
|
|
-y
|
|
|
|
shell: bash
|
2022-07-04 06:16:11 -04:00
|
|
|
|
|
|
|
# TODO: Replace with https://github.com/sigstore/sigstore-installer/tree/initial
|
|
|
|
# once it has the functionality
|
|
|
|
- name: Install Cosign
|
|
|
|
uses: sigstore/cosign-installer@main
|
|
|
|
- name: Install Rekor
|
|
|
|
run: |
|
|
|
|
curl -LO https://github.com/sigstore/rekor/releases/download/v0.9.0/rekor-cli-linux-amd64
|
|
|
|
sudo install rekor-cli-linux-amd64 /usr/local/bin/rekor-cli
|
|
|
|
shell: bash
|
|
|
|
|
2022-06-30 05:27:23 -04:00
|
|
|
# https://github.blog/2022-04-12-git-security-vulnerability-announced/
|
|
|
|
- name: Mark repository safe
|
|
|
|
run: |
|
|
|
|
git config --global --add safe.directory /__w/constellation/constellation
|
|
|
|
shell: bash
|
2022-06-23 11:52:25 -04:00
|
|
|
|
2022-06-30 05:27:23 -04:00
|
|
|
- name: Install Go
|
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version: "1.18"
|
2022-07-04 06:16:11 -04:00
|
|
|
- name: Build hack/pcr-reader
|
|
|
|
run: |
|
|
|
|
go build .
|
|
|
|
echo "$(pwd)" >> $GITHUB_PATH
|
|
|
|
export PATH="$PATH:$(pwd)"
|
|
|
|
working-directory: hack/pcr-reader
|
|
|
|
shell: bash
|
|
|
|
|
2022-06-30 05:27:23 -04:00
|
|
|
- name: Build CLI
|
|
|
|
run: |
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake ..
|
|
|
|
make -j`nproc` cli
|
|
|
|
echo "$(pwd)" >> $GITHUB_PATH
|
|
|
|
export PATH="$PATH:$(pwd)"
|
|
|
|
shell: bash
|
2022-07-04 06:16:11 -04:00
|
|
|
|
|
|
|
- name: Sign CLI
|
2022-06-30 05:27:23 -04:00
|
|
|
run: |
|
2022-07-04 06:16:11 -04:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
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 constellation > constellation.sig
|
|
|
|
# Verify - As documentation & check
|
|
|
|
# Local Signature (input: artifact, key, signature)
|
|
|
|
cosign verify-blob --key cosign.pub --signature constellation.sig constellation
|
|
|
|
# Transparency Log Signature (input: artifact, key)
|
|
|
|
uuid=$(rekor-cli search --artifact constellation | tail -n 1)
|
|
|
|
sig=$(rekor-cli get --uuid=$uuid --format=json | jq -r .Body.HashedRekordObj.signature.content)
|
|
|
|
cosign verify-blob --key cosign.pub --signature <(echo $sig) constellation
|
2022-06-30 05:27:23 -04:00
|
|
|
shell: bash
|
2022-07-04 06:16:11 -04:00
|
|
|
working-directory: build
|
|
|
|
env:
|
|
|
|
COSIGN_PUBLIC_KEY: ${{ inputs.cosign-public-key }}
|
|
|
|
COSIGN_PRIVATE_KEY: ${{ inputs.cosign-private-key }}
|
|
|
|
COSIGN_PASSWORD: ${{ inputs.cosign-password }}
|
2022-07-07 06:18:41 -04:00
|
|
|
if: ${{ inputs.cosign-public-key != '' && inputs.cosign-private-key != '' && inputs.cosign-password != '' }}
|
2022-07-04 06:16:11 -04:00
|
|
|
|
|
|
|
- name: Release CLI
|
|
|
|
# GitHub endorsed release project. See: https://github.com/actions/create-release
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
with:
|
|
|
|
draft: true
|
|
|
|
files: |
|
2022-07-05 10:55:14 -04:00
|
|
|
build/constellation
|
|
|
|
build/constellation.sig
|
|
|
|
build/cosign.pub
|