Skip to content
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

Addition of a workflow for SLSA-compliant build and publishing #291

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build for SLSA
on:
release:
types: [published]

jobs:
build:
runs-on: "ubuntu-latest"
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Build Wheel and Generate checksum
id: build
run: |
pip install build
python -m pip install -r requirements.txt
python -m build
- name: Generate Python SBOM
id: sbom-json
uses: CycloneDX/gh-python-generate-sbom@v2
with:
input: ./requirements.txt
output: dist/generated_bom.json
format: json # output format (json)
- name: Generate Python SBOM
id: sbom-xml
uses: CycloneDX/gh-python-generate-sbom@v2
with:
input: ./requirements.txt
output: dist/generated_bom.xml
format: json # output format (xml)
- name: Generate subject
id: hash
run: |
cd dist
HASHES=$(sha256sum * | base64 -w0)
echo "hashes=$HASHES" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
name: release
with:
path: dist/


provenance:
needs: [build]
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
permissions:
actions: read
id-token: write
contents: write
with:
base64-subjects: ${{ needs.build.outputs.hashes }}


publish:
needs: ["provenance"]
permissions:
contents: write
runs-on: "ubuntu-latest"
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Generate list of files to upload
id: filelist
run: |
echo "list<<EOF" >> "$GITHUB_OUTPUT"
find dist/ -type f >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Release
uses: softprops/[email protected]
with:
files: ${{ steps.filelist.outputs.list }}