Skip to content

Commit

Permalink
build: Add provenance generation to release process
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Mar 4, 2024
1 parent 276aa67 commit 04f9529
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: 'Which ghc version to use when building the package'
required: false
default: 8.10.7
outputs:
package-hashes:
description: "base64-encoded sha256 hashes of distribution files"
value: ${{ steps.package-hashes.outputs.package-hashes }}

runs:
using: composite
Expand All @@ -26,6 +30,17 @@ runs:
shell: bash
run: stack --no-terminal --resolver=${{ inputs.resolver }} sdist

- name: Setup dist directory
shell: bash
run: echo "STACK_DIR=$(stack --no-terminal path --dist-dir --resolver=${{ inputs.resolver }})" >> $GITHUB_ENV

- name: Hash build files for provenance
id: package-hashes
shell: bash
working-directory: ${{ env.STACK_DIR }}
run: |
echo "package-hashes=$(sha256sum *tar.gz | base64 -w0)" >> "$GITHUB_OUTPUT"
- name: Run tests
shell: bash
run: stack --no-terminal --resolver=${{ inputs.resolver }} test
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- resolver: lts-18.28
Expand Down Expand Up @@ -41,6 +42,7 @@ jobs:
runs-on: macos-latest

strategy:
fail-fast: false
matrix:
include:
- resolver: lts-18.28
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ jobs:
permissions:
id-token: write
contents: read
outputs:
package-hashes: ${{ steps.ci.outputs.package-hashes }}

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-cache

- name: Build and Test
id: ci
uses: ./.github/actions/ci

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.0
Expand All @@ -34,3 +37,14 @@ jobs:
with:
token: ${{ env.HACKAGE_TOKEN }}
dry_run: ${{ inputs.dry_run }}

release-provenance:
needs: [ 'build-publish' ]
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.7.0
with:
base64-subjects: "${{ needs.build-publish.outputs.package-hashes }}"
upload-assets: ${{ !inputs.dry_run }}
18 changes: 18 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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.ci.outputs.package-hashes }}

steps:
- uses: google-github-actions/release-please-action@v3
Expand Down Expand Up @@ -48,6 +52,7 @@ jobs:
if: ${{ steps.release.outputs.releases_created }}

- uses: ./.github/actions/ci
id: ci
if: ${{ steps.release.outputs.releases_created }}

- uses: ./.github/actions/build-docs
Expand All @@ -65,3 +70,16 @@ jobs:
# If publishing somewhere else, then get the token from SSM. If you need both github,
# and another token, then add more tokens to the composite action.
token: ${{secrets.GITHUB_TOKEN}}

release-provenance:
needs: [ 'release-package' ]
if: ${{ needs.release-package.outputs.release-created }}
permissions:
actions: read
id-token: write
contents: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.7.0
with:
base64-subjects: "${{ needs.release-package.outputs.package-hashes }}"
upload-assets: true
upload-tag-name: ${{ needs.release-package.outputs.upload-tag-name }}
5 changes: 5 additions & 0 deletions PROVENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 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.intoto.jsonl`.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ We run integration tests for all our SDKs using a centralized test harness. This

We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.

## 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. To learn more, see the [provenance guide](PROVENANCE.md).

## About LaunchDarkly

* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
Expand Down

0 comments on commit 04f9529

Please sign in to comment.