Skip to content

Commit 8c82608

Browse files
authored
fix: adding slsa provenance generation to release-client workflow (#212)
Using [generic SLSA provenance generator ](https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/generic/README.md#a-different-attestation-for-each-iteration) to build provenance attestations for our client SDK artifacts. [Tech spec for reference ](https://launchdarkly.atlassian.net/wiki/spaces/SEC/pages/2529919025/Integrating+SLSA+compliance+with+SDK+release+workflows#Provenance-only-generator) Since we're using a matrix strategy for the build, there will be one attestation file for all the artifacts for each platform (i.e., attestation for Linux artifacts, one for Windows artifacts, one for MacOS artifacts). Based off of POC here: https://github.com/launchdarkly/learn-release-please/pull/35/files though this time it should be more accurate since we're hashing the exact artifacts that we're uploading to the Github release, whereas there wasn't a good way to do that with the yarn-generated package in the POC repo.
2 parents 32392c9 + 591d25d commit 8c82608

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/actions/sdk-release/action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ inputs:
1818
required: true
1919
sdk_cmake_target:
2020
description: 'CMake target of the sdk, e.g. launchdarkly-cpp-client.'
21+
outputs:
22+
hashes-linux:
23+
description: "base64-encoded sha256 hash of linux build artifacts"
24+
value: ${{ steps.hash-linux.outputs.hashes-linux }}
25+
hashes-windows:
26+
description: "base64-encoded sha256 hash of windows build artifacts"
27+
value: ${{ steps.hash-windows.outputs.hashes-windows }}
28+
hashes-macos:
29+
description: "base64-encoded sha256 hash of macos build artifacts"
30+
value: ${{ steps.hash-macos.outputs.hashes-macos }}
2131

2232
runs:
2333
using: composite
@@ -56,6 +66,12 @@ runs:
5666
type: 'zip'
5767
filename: 'linux-gcc-x64-dynamic.zip'
5868

69+
- name: Hash Linux Build Artifacts for provenance
70+
if: runner.os == 'Linux'
71+
shell: bash
72+
id: hash-linux
73+
run: |
74+
echo "hashes-linux=$(sha256sum linux-gcc-x64-static.zip linux-gcc-x64-dynamic.zip | base64 -w0)" >> "$GITHUB_OUTPUT"
5975
6076
- name: Upload Linux Build Artifacts
6177
if: runner.os == 'Linux'
@@ -118,6 +134,13 @@ runs:
118134
type: 'zip'
119135
filename: 'windows-msvc-x64-dynamic-debug.zip'
120136

137+
- name: Hash Windows Build Artifacts for provenance
138+
if: runner.os == 'Windows'
139+
shell: bash
140+
id: hash-windows
141+
run: |
142+
echo "hashes-windows=$(sha256sum windows-msvc-x64-static.zip windows-msvc-x64-dynamic.zip windows-msvc-x64-static-debug.zip windows-msvc-x64-dynamic-debug.zip | base64 -w0)" >> "$GITHUB_OUTPUT"
143+
121144
- name: Upload Windows Build Artifacts
122145
if: runner.os == 'Windows'
123146
shell: bash
@@ -157,6 +180,13 @@ runs:
157180
type: 'zip'
158181
filename: 'mac-clang-x64-dynamic.zip'
159182

183+
- name: Hash Mac Build Artifacts for provenance
184+
if: runner.os == 'macOS'
185+
shell: bash
186+
id: hash-macos
187+
run: |
188+
echo "hashes-macos=$(sha256sum mac-clang-x64-static.zip mac-clang-x64-dynamic.zip | base64 -w0)" >> "$GITHUB_OUTPUT"
189+
160190
- name: Upload Mac Build Artifacts
161191
if: runner.os == 'macOS'
162192
shell: bash

.github/workflows/release-please.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727
needs: [ 'release-please' ]
2828
if: ${{ needs.release-please.outputs.package-client-released }}
29+
outputs:
30+
hashes-linux: ${{ steps.release-client.outputs.hashes-linux }}
31+
hashes-windows: ${{ steps.release-client.outputs.hashes-windows }}
32+
hashes-macos: ${{ steps.release-client.outputs.hashes-macos }}
2933
steps:
3034
- uses: actions/checkout@v3
3135
- id: release-client
@@ -37,3 +41,17 @@ jobs:
3741
github_token: ${{secrets.GITHUB_TOKEN}}
3842
sdk_path: 'libs/client-sdk'
3943
sdk_cmake_target: 'launchdarkly-cpp-client'
44+
45+
release-client-provenance:
46+
needs: ['release-client']
47+
strategy:
48+
matrix:
49+
# Generates a combined attestation for each platform
50+
os: [ linux, windows, macos ]
51+
permissions:
52+
actions: read
53+
id-token: write
54+
contents: write
55+
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
56+
with:
57+
base64-subjects: "${{ needs.release-client.outputs[format('hashes-{0}', matrix.os)] }}"

0 commit comments

Comments
 (0)