-
Notifications
You must be signed in to change notification settings - Fork 19
Add a workflow to release and sign wheels #22
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
agriyakhetarpal
wants to merge
19
commits into
ziglang:main
Choose a base branch
from
agriyakhetarpal:add-pypi-workflow
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.
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e18f13a
Add workflow to release and sign wheels
agriyakhetarpal cf9845e
Move condition to PyPI publishing step
agriyakhetarpal 918e372
Merge branch 'main' into add-pypi-workflow
agriyakhetarpal 2deb188
Permanent GHA Attestations, update dependencies
agriyakhetarpal cd48f0c
Add a comment about the `twine` optional dep
agriyakhetarpal fb443f3
Rename from `cd.yaml` to `cd.yml`
agriyakhetarpal debaeea
Add a section on build provenance and verifying it
agriyakhetarpal f5424ee
Make the `push_to_pypi:` input explicit
agriyakhetarpal 55bdcc9
Move condition for PyPI trigger to the job
agriyakhetarpal b808dfa
Merge branch 'main' into add-pypi-workflow
agriyakhetarpal e6cde54
Add GitHub job summary for inspecting built wheels
agriyakhetarpal 57118e8
Temporarily trigger on pull requests
agriyakhetarpal 3018f12
Raise an error if no artifacts to upload
agriyakhetarpal cdfa62f
Temporarily allow triggering manually via fork
agriyakhetarpal cad440f
Temporarily disable commands
agriyakhetarpal 1bbd3d2
Fix `pdm` invocation
agriyakhetarpal 8340fa1
`pdm` is a build-time dependency, not a run-time one
agriyakhetarpal 68b5352
Fix summary printing
agriyakhetarpal 5f8a524
Clean up changes and add a sanity check
agriyakhetarpal 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: CD | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to build Zig wheels for' | ||
required: true | ||
default: 'latest' | ||
suffix: | ||
description: > | ||
Suffix to append to the version in the wheel filename, useful for dev versions and version specifiers | ||
required: false | ||
default: '' | ||
platforms: | ||
description: > | ||
Comma-separated values of platforms to build wheels for | ||
required: false | ||
default: 'x86_64-windows,x86-windows,x86_64-macos,aarch64-macos,i386-linux,x86-linux,x86_64-linux,aarch64-linux,armv7a-linux' | ||
push_to_pypi: | ||
description: > | ||
Whether to push the built wheels to PyPI. Can be 'true' or 'false', defaults to 'false'. | ||
required: false | ||
agriyakhetarpal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default: 'false' | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install . | ||
|
||
- name: Build wheels for all platforms | ||
shell: bash | ||
run: | | ||
platforms=${{ github.event.inputs.platforms }} | ||
IFS=',' read -r -a platform_array <<< "$platforms" | ||
for platform in "${platform_array[@]}"; do | ||
python make_wheels.py \ | ||
--version ${{ github.event.inputs.version }} \ | ||
--suffix ${{ github.event.inputs.suffix }} \ | ||
--platform "$platform" | ||
done | ||
|
||
- name: Upload wheel artifacts | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: zig-wheels | ||
path: dist/*.whl | ||
|
||
deploy_wheels: | ||
name: Deploy wheels | ||
needs: [build_wheels] | ||
environment: pypi | ||
runs-on: ubuntu-latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
permissions: | ||
# Required by | ||
# 1. OIDC to publish to PyPI, and | ||
# 2. Sigstore to sign artifacts | ||
id-token: write | ||
if: >- | ||
github.event_name == 'workflow_dispatch' && | ||
github.event.inputs.push_to_pypi == 'true' && | ||
github.repository == 'ziglang/zig-pypi' | ||
agriyakhetarpal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
steps: | ||
- name: Download wheel artifacts | ||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
with: | ||
path: dist/ | ||
merge-multiple: true | ||
|
||
- name: Publish wheels to PyPI | ||
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 | ||
with: | ||
packages-dir: dist/ | ||
|
||
- name: Sign artifacts with Sigstore | ||
uses: sigstore/gh-action-sigstore-python@61f6a500bbfdd9a2a339cf033e5421951fbc1cd2 # v2.1.1 | ||
with: | ||
inputs: >- | ||
./dist/*.whl | ||
|
||
- name: Upload signed artifacts and signature files | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
# This will contain not only the wheels but also the signature files | ||
# generated by the Sigstore step | ||
path: dist/* | ||
agriyakhetarpal marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Uh oh!
There was an error while loading. Please reload this page.