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

Add a workflow to release and sign wheels #22

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

agriyakhetarpal
Copy link
Contributor

Description

Partially addresses issues raised in #20. This PR adds a workflow to release wheels to PyPI and sign them.

These changes are in response to the comment:

I think we can start with a workflow responding to workflow_dispatch event where the workflow itself uses both Sigstore and Trusted Publishing, with the pushing of wheels still being manual. Then we can consider something more automated after that.

and the workflow is meant to be triggered manually.

Changes made

  1. A workflow that responds to the manual workflow_dispatch: trigger, with customisable inputs for enabling the version to build wheels for, the suffix to append to the version, platforms to build wheels for (might be redundant), and lastly, a push_to_pypi input which is false by default, but can be set to true to trigger the deployment job.
  2. The deployment job is separate from the job that builds wheels because to isolate the environment associated with the job, and the extra permissions that it requires. Artifacts (in this case, wheels) are shared between jobs.
  3. The deployment job signs the wheels and generates .sigstore files, which can be used to verify that the wheels were indeed generated inside a GitHub Actions workflow.

Additional context

To further mitigate actors bearing malicious intent, I would recommend adding a CODEOWNERS file or some sort of branch protection so that it is not easy for others to modify the workflow and trigger it. Currently, those with triage access can trigger workflows. The environment with the name pypi has to be set up and requests to use it to deploy have to be manually approved by a repository administrator or someone with the appropriate permissions, so, I would recommend keeping that stringent

.github/workflows/cd.yaml Outdated Show resolved Hide resolved
.github/workflows/cd.yaml Outdated Show resolved Hide resolved
Comment on lines 60 to 62
needs: [build_wheels]
environment: pypi
runs-on: ubuntu-latest
Copy link
Contributor Author

@agriyakhetarpal agriyakhetarpal Apr 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This environment will have to be created in the repository settings, as noted in the PR description. It will trigger the workflow, but the deployment will pass only if it gets approved, and the publishing step won't be triggered until so.

.github/workflows/cd.yaml Outdated Show resolved Hide resolved
.github/workflows/cd.yaml Outdated Show resolved Hide resolved
@agriyakhetarpal
Copy link
Contributor Author

Here's a brief implementation as requested, @whitequark – would appreciate general comments based on how you would like to refine it and whether it fits with the ideas that you had in mind :)

@whitequark
Copy link
Collaborator

Thanks, impressive work! I won't have time to review it until a week or two from now most likely.

@agriyakhetarpal
Copy link
Contributor Author

Good news: this entire workflow is now all the more easy to implement with the GitHub Actions Attestations feature, which has been generally available for some time now. Let me restructure this PR later in the day, I'm happy to answer any questions as needed.

@agriyakhetarpal
Copy link
Contributor Author

Having a place to put them permanently would serve some part of the reproducibility issues discussed

Once added, the attestations would become permanently available at https://github.com/ziglang/zig-pypi/attestations for anyone to download and verify.

@whitequark
Copy link
Collaborator

Sounds good.

@agriyakhetarpal
Copy link
Contributor Author

Okay, this is ready now! I even added a short but nice (and extensible) Markdown summary for looking at what wheel artifacts were built: https://github.com/agriyakhetarpal/zig-pypi/actions/runs/11176994453/attempts/1#summary-31071679824. There is no hurry from my side for a review – I'm just always excited to contribute to this fantastic project that I get to use.

@agriyakhetarpal
Copy link
Contributor Author

Attestations at the PyPI level now available, too, here's the announcement: https://blog.pypi.org/posts/2024-11-14-pypi-now-supports-digital-attestations/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants