-
Notifications
You must be signed in to change notification settings - Fork 83
Automatic wheels building for PyPI #1290
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
base: master
Are you sure you want to change the base?
Changes from all commits
0103738
190e9e6
358ebbb
612ce71
015690f
4cb35b9
e5f7b7b
00b0c84
8ed47a4
1114eaf
d1efb67
04d8696
9c13686
3d0b3ab
6cdf427
0f422c1
2e6a6e8
aab0184
9c224c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,111 @@ | ||
| name: Upload to PyPI | ||
| name: Build and publish to PyPI | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| Upload: | ||
| build_wheels: | ||
| name: Build wheels on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| cibw_archs: x86_64 | ||
| - os: macos-latest | ||
| cibw_archs: arm64 | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Build wheels | ||
| uses: pypa/cibuildwheel@v3.3.1 | ||
| env: | ||
| CIBW_ARCHS: ${{ matrix.cibw_archs }} | ||
|
|
||
| - name: Upload wheels | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cibw-wheels-${{ matrix.os }}-${{ matrix.cibw_archs }} | ||
| path: ./wheelhouse/*.whl | ||
|
|
||
| build_sdist: | ||
| name: Build source distribution | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Install build dependencies | ||
| run: python -m pip install --upgrade pip build | ||
|
|
||
| - name: Build sdist | ||
| run: python -m build --sdist | ||
|
|
||
| - name: Upload sdist | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cibw-sdist | ||
| path: dist/*.tar.gz | ||
|
|
||
| publish_testpypi: | ||
| name: Publish to TestPyPI | ||
| needs: [build_wheels, build_sdist] | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'workflow_dispatch' | ||
| environment: | ||
| name: testpypi | ||
| url: https://test.pypi.org/p/pyccl | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: cibw-* | ||
| path: dist | ||
| merge-multiple: true | ||
|
|
||
| - name: Publish to TestPyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
|
|
||
| publish: | ||
| name: Publish to PyPI | ||
| needs: [build_wheels, build_sdist] | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'release' | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/p/pyccl | ||
| permissions: | ||
| contents: read | ||
| id-token: write # Required for trusted publishing | ||
| id-token: write | ||
|
|
||
|
Collaborator
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. Here, copilot suggested to add an
Author
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. Yeah, that is required by trusted publishing, I've added that. |
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install build dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install build | ||
|
|
||
| - name: Build source tarball only | ||
| run: | | ||
| python -m build --sdist | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| password: ${{ secrets.PYPI_PYCCL_UPLOAD }} | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: cibw-* | ||
| path: dist | ||
| merge-multiple: true | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
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 you add a block for test.pypi? Just to make sure the release doesn't break the official packages.
This was suggested by copilot.
@damonge, @c-d-leonard I think we need your intervention to set up the identity provider in test-pypi https://test.pypi.org/project/pyccl/. Also, it might be good if you add desc-ccl as maintainer (which I believe is what we use to publish to pypi?).
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.
Added, as you say, also in the next comments, I am assuming that trusted publishing is set up. So maybe some work is required by maintainers to fix that, if that is not true.