Skip to content

Commit

Permalink
Restore github release provenance + provenance signing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofranssen committed Feb 18, 2022
1 parent 3645ec0 commit 1a66b6c
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,47 @@ jobs:
docker logout ghcr.io
rm -f cosign.key
provenance:
name: provenance
needs: [release]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04

steps:
- name: Generate provenance for Release
uses: philips-labs/slsa-provenance-action@v0.7.1
with:
command: generate
subcommand: github-release
arguments: --artifact-path release-assets --output-path provenance.att --tag-name ${{ github.ref_name }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Install cosign
uses: sigstore/cosign-installer@v2.0.0
with:
cosign-release: 'v1.5.1'

- name: Sign provenance
run: |
echo '${{ secrets.COSIGN_PRIVATE_KEY }}' > cosign.key
cosign sign-blob --key cosign.key --output-signature "${SIGNATURE}" provenance.att
cat "${SIGNATURE}"
curl_args=(-s -H "Authorization: token ${GITHUB_TOKEN}")
curl_args+=(-H "Accept: application/vnd.github.v3+json")
release_id="$(curl "${curl_args[@]}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases?per_page=10" | jq "map(select(.name == \"${GITHUB_REF_NAME}\"))" | jq -r '.[0].id')"
echo "Upload ${SIGNATURE} to release with id ${release_id}…"
curl_args+=(-H "Content-Type: $(file -b --mime-type "${SIGNATURE}")")
curl "${curl_args[@]}" \
--data-binary @"${SIGNATURE}" \
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${SIGNATURE}"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
SIGNATURE: provenance.att.sig

container-provenance:
name: container-provenance
needs: [release]
Expand All @@ -208,7 +249,7 @@ jobs:
cosign-release: 'v1.5.1'

- name: Generate provenance for ${{ matrix.repo }}
uses: philips-labs/slsa-provenance-action@v0.8.1-draft
uses: philips-labs/slsa-provenance-action@v0.7.1
with:
command: generate
subcommand: container
Expand Down

0 comments on commit 1a66b6c

Please sign in to comment.