-
Notifications
You must be signed in to change notification settings - Fork 14
PyPI publication workflow: Generate package SBOM in wheel #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bact
wants to merge
11
commits into
JPEWdev:main
Choose a base branch
from
bact:gen-sbom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−3
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2fb7824
Add Pitloom to generate package SBOM in wheel
bact 8d5ca6a
Update hatchling version requirement to 1.29.0
bact ee278ae
Merge branch 'JPEWdev:main' into gen-sbom
bact cad1798
Merge branch 'JPEWdev:main' into gen-sbom
bact 49e3673
Use Pitloom GitHub Action instead of Hatchling hook
bact 0f28686
Enable content-type scan
bact d7259d4
Update Pitloom to 0.16.0
bact f172589
Update pitloom action version to v0.16.1
bact c90a09f
Enable content-type detection
bact 1ed1771
Remove content-type config from pyproject.toml
bact 1938b36
Add test-sbom.yml
bact File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,73 @@ | ||
| --- | ||
| # Tests that the SBOM generation and embedding step works correctly on every PR. | ||
| name: Test SBOM generation | ||
|
|
||
| on: | ||
| push: | ||
| paths-ignore: &ignore-paths | ||
| - "docs/**" | ||
| - "**/*.md" | ||
| - "LICENSE*" | ||
| pull_request: | ||
| paths-ignore: *ignore-paths | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test-sbom: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | ||
| with: | ||
| python-version: "3.x" | ||
| cache: pip | ||
|
|
||
| - name: Install build tooling | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build spdx3-validate | ||
|
|
||
| - name: Build wheel | ||
| run: python -m build --wheel | ||
|
|
||
| - name: Embed SBOM into the wheel | ||
| id: pitloom | ||
| uses: bact/pitloom@4842922f65fb7ed1c5e51507c0fb253c62d97960 # v0.16.2 | ||
| with: | ||
| embed-wheel: "dist/*.whl" | ||
| extras: "content-type" | ||
| content-type: "true" | ||
| artifact-name: "sbom" | ||
|
|
||
| - name: Extract and validate embedded SBOM | ||
| env: | ||
| SBOM_PATH: ${{ steps.pitloom.outputs.sbom-path }} | ||
| run: | | ||
| set -euo pipefail | ||
| whl=$(ls dist/*.whl) | ||
| sbom_basename=$(basename "${SBOM_PATH}") | ||
|
|
||
| entry="" | ||
| while IFS= read -r line; do | ||
| case "${line}" in | ||
| *".dist-info/sboms/${sbom_basename}") entry="${line}"; break ;; | ||
| esac | ||
| done < <(unzip -Z1 "${whl}") | ||
|
|
||
| if [ -z "${entry}" ]; then | ||
| echo "::error::${sbom_basename} not found under */.dist-info/sboms/ in ${whl}" | ||
| exit 1 | ||
| fi | ||
| echo "Found: ${entry}" | ||
|
|
||
| mkdir -p extracted-sbom | ||
| unzip -p "${whl}" "${entry}" > "extracted-sbom/${sbom_basename}" | ||
| spdx3-validate --json "extracted-sbom/${sbom_basename}" |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we run this during the normal build workflow also so there are no surprises when we publish?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can. Will update the test.yml for that. Or maybe a dedicated SBOM generation test workflow.