-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: adding provenance generation to release-please workflow (#256)
**Requirements** - [ ] I have added test coverage for new or changed functionality - [ ] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [ ] I have validated my changes against all supported platform versions **Related issues** Provide links to any issues in this repository or elsewhere relating to this pull request. **Describe the solution you've provided** Using Github SLSA generator to generate build provenance for `python-server-sdk` Implementation based off of previous SDK SLSA integrations with release-please and Python-specific guidance here: https://sethmlarson.dev/python-and-slsa#generating-a-provenance-attestation **Describe alternatives you've considered** Provide a clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context about the pull request here.
- Loading branch information
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
name: Build distribution files | ||
description: 'Build distribution files' | ||
outputs: | ||
package-hashes: | ||
description: "base64-encoded sha256 hashes of distribution files" | ||
value: ${{ steps.package-hashes.outputs.package-hashes }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Build distribution files | ||
shell: bash | ||
run: poetry build | ||
- name: Hash build files for provenance | ||
id: package-hashes | ||
shell: bash | ||
working-directory: ./dist | ||
run: | | ||
echo "package-hashes=$(sha256sum * | base64 -w0)" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ jobs: | |
permissions: | ||
id-token: write | ||
contents: read | ||
outputs: | ||
package-hashes: ${{ steps.build.outputs.package-hashes}} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
|
@@ -31,8 +33,21 @@ jobs: | |
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' | ||
|
||
- uses: ./.github/actions/build | ||
id: build | ||
|
||
- uses: ./.github/actions/publish | ||
with: | ||
token: ${{env.PYPI_AUTH_TOKEN}} | ||
dry_run: ${{ inputs.dry_run }} | ||
|
||
release-provenance: | ||
needs: [ 'build-publish' ] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
id-token: write | ||
contents: write | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
base64-subjects: "${{ needs.build-publish.outputs.package-hashes }}" | ||
upload-assets: ${{ !inputs.dry_run }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,10 @@ jobs: | |
id-token: write # Needed if using OIDC to get release secrets. | ||
contents: write # Contents and pull-requests are for release-please to make releases. | ||
pull-requests: write | ||
outputs: | ||
release-created: ${{ steps.release.outputs.release_created }} | ||
upload-tag-name: ${{ steps.release.outputs.tag_name }} | ||
package-hashes: ${{ steps.build.outputs.package-hashes}} | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
|
@@ -41,6 +45,7 @@ jobs: | |
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN' | ||
|
||
- uses: ./.github/actions/build | ||
id: build | ||
if: ${{ steps.release.outputs.releases_created }} | ||
|
||
- uses: ./.github/actions/build-docs | ||
|
@@ -51,3 +56,17 @@ jobs: | |
with: | ||
token: ${{env.PYPI_AUTH_TOKEN}} | ||
dry_run: false | ||
|
||
release-provenance: | ||
needs: [ 'release-package' ] | ||
if: ${{ needs.release-package.outputs.release-created }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
id-token: write | ||
contents: write | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
base64-subjects: "${{ needs.release-package.outputs.package-hashes }}" | ||
upload-assets: true | ||
upload-tag-name: ${{ needs.release-package.outputs.upload-tag-name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Verifying SDK build provenance with the SLSA framework | ||
|
||
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. | ||
|
||
As part of [SLSA requirements for level 3 compliance](https://slsa.dev/spec/v1.0/requirements), LaunchDarkly publishes provenance about our SDK package builds using [GitHub's generic SLSA3 provenance generator](https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/generic/README.md#generation-of-slsa3-provenance-for-arbitrary-projects) for distribution alongside our packages. These attestations are available for download from the GitHub release page for the release version under Assets > `multiple-provenance.intoto.jsonl`. | ||
|
||
To verify SLSA provenance attestations, we recommend using [slsa-verifier](https://github.com/slsa-framework/slsa-verifier). Example usage for verifying SDK packages is included below: | ||
|
||
``` | ||
# Download packages from PyPi | ||
$ pip download --only-binary=:all: launchdarkly-server-sdk | ||
# Download provenance from Github release | ||
$ curl --location -O \ | ||
https://github.com/launchdarkly/python-server-sdk/releases/download/VERSION/multiple.intoto.jsonl | ||
# Run slsa-verifier to verify provenance against package artifacts | ||
$ slsa-verifier verify-artifact \ | ||
--provenance-path multiple-provenance.intoto.jsonl \ | ||
--source-uri github.com/launchdarkly/python-server-sdk \ | ||
launchdarkly_server_sdk-VERSION-py3-none-any.whl | ||
``` | ||
|
||
Alternatively, to verify the provenance manually, the SLSA framework specifies [recommendations for verifying build artifacts](https://slsa.dev/spec/v1.0/verifying-artifacts) in their documentation. | ||
|
||
**Note:** These instructions do not apply when building our SDKs from source. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters