-
Notifications
You must be signed in to change notification settings - Fork 1
patch: Add SLSA provenance to release assets #217
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
Conversation
See https://slsa.dev/ for motivation. Creating a patch release to ensure these additions to the automated release process work. Note that the `release` job has been subdivided, because the SLSA provenance reusable workflow cannot be used as a step within a job, but must be used as a job on its own.
Reviewer's GuideThis PR refactors the semantic-release GitHub Actions workflow to centralize concurrency, compute and upload artifact hashes, generate SLSA provenance attestations, and introduce a dedicated publish job that hardens the runner, aggregates artifacts and provenance, and publishes to GitHub Releases and PyPI. Flow diagram for the new release and publish processflowchart TD
Start([Start]) --> Release[Release Job]
Release -->|If released| Hash[Hash Build Artifacts]
Hash --> Upload[Upload Build Artifacts]
Upload --> Provenance[Provenance Job]
Provenance --> Publish[Publish Job]
Publish -->|Download Artifacts & Provenance| Aggregate[Aggregate Artifacts]
Aggregate -->|Remove Provenance for PyPI| Clean[Clean Artifacts]
Clean -->|Publish| GitHub[GitHub Releases]
Clean -->|Publish| PyPI[PyPI]
GitHub --> End([End])
PyPI --> End
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @jmgate - I've reviewed your changes - here's some feedback:
- In the provenance job, explicitly upload the generated provenance file (e.g. with actions/upload-artifact) so that the publish job’s download-artifact step can reliably fetch it.
- Add a validation step in the publish job to verify the downloaded provenance file matches the computed artifact hashes before publishing to ensure integrity.
- Consider parameterizing the artifact and provenance filenames/paths (instead of hardcoding in rm -f) to make future workflow updates less error-prone.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the provenance job, explicitly upload the generated provenance file (e.g. with actions/upload-artifact) so that the publish job’s download-artifact step can reliably fetch it.
- Add a validation step in the publish job to verify the downloaded provenance file matches the computed artifact hashes before publishing to ensure integrity.
- Consider parameterizing the artifact and provenance filenames/paths (instead of hardcoding in rm -f) to make future workflow updates less error-prone.
## Individual Comments
### Comment 1
<location> `.github/workflows/semantic-release.yml:42` </location>
<code_context>
- - name: Publish to PyPI
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
+ - name: Hash Build Artifacts
+ if: steps.release.outputs.released == 'true'
+ id: hash
+ run: |
+ cd dist
+ echo "hashes=$(find . -type f -exec sha256sum {} + | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT"
+
+ - name: Upload Build Artifacts
</code_context>
<issue_to_address>
The artifact hashing step may not be robust to non-ASCII filenames or large numbers of files.
Using `find . -type f -exec sha256sum {} + | sort | base64` may not handle filenames with spaces, newlines, or non-ASCII characters correctly. Consider `find . -type f -print0 | xargs -0 sha256sum` for better robustness. Also, be aware of potential command limits with very large file counts.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
echo "hashes=$(find . -type f -exec sha256sum {} + | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT"
=======
echo "hashes=$(find . -type f -print0 | xargs -0 sha256sum | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT"
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| id: hash | ||
| run: | | ||
| cd dist | ||
| echo "hashes=$(find . -type f -exec sha256sum {} + | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT" |
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.
suggestion: The artifact hashing step may not be robust to non-ASCII filenames or large numbers of files.
Using find . -type f -exec sha256sum {} + | sort | base64 may not handle filenames with spaces, newlines, or non-ASCII characters correctly. Consider find . -type f -print0 | xargs -0 sha256sum for better robustness. Also, be aware of potential command limits with very large file counts.
| echo "hashes=$(find . -type f -exec sha256sum {} + | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT" | |
| echo "hashes=$(find . -type f -print0 | xargs -0 sha256sum | sort | base64 | tr -d '\n')" >> "$GITHUB_OUTPUT" |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #217 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 176 176
Branches 15 15
=========================================
Hits 176 176 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Type: Task
Description
See sandialabs/reverse_argparse#315.
Summary by Sourcery
Integrate SLSA provenance generation into the release pipeline by restructuring the semantic-release workflow into separate release, provenance, and publish jobs with artifact hashing, uploading, runner hardening, and cleanup steps.
New Features:
Enhancements:
CI: