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 source distribution upload to the PyPi-cd workflow #3213

Merged
merged 9 commits into from
Feb 23, 2025
Merged
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
35 changes: 30 additions & 5 deletions .github/workflows/pypi-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs:
fail-fast: false
matrix:
build: ${{ fromJson(needs.load-platform-matrix.outputs.PLATFORM_MATRIX) }}
outputs:
release_version: ${{ steps.set_version.outputs.RELEASE_VERSION }}
steps:
- name: Setup self-hosted runner access
if: ${{ contains(matrix.build.RUNNER, 'self-hosted') }}
Expand All @@ -91,6 +93,7 @@ jobs:
submodules: "true"

- name: Set the release version
id: set_version
shell: bash
run: |
if ${{ env.EVENT_NAME == 'pull_request' }}; then
Expand All @@ -101,6 +104,7 @@ jobs:
R_VERSION=${GITHUB_REF:11}
fi
echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_ENV
echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_OUTPUT
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_VERSION: ${{ github.event.inputs.version }}
Expand Down Expand Up @@ -198,31 +202,52 @@ jobs:
path: python/wheels
if-no-files-found: error

publish-to-pypi:
build-source-dist-and-publish-to-pypi:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I propose to create another job to build sources and add it there as a dependency (needs section)

Copy link
Collaborator

Choose a reason for hiding this comment

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

It will require to upload the build files and then download them, I think it's unnecessary and makes sense to keep it in the same job due to this reason

if: github.event_name != 'pull_request'
name: Publish the base PyPi package
runs-on: ubuntu-latest
needs: publish-binaries
steps:
- uses: actions/download-artifact@v4
- name: Checkout
uses: actions/checkout@v4

- name: Set the release version
shell: bash
run: |
echo "RELEASE_VERSION=${{needs.publish-binaries.outputs.release_version}}" >> $GITHUB_ENV

- name: Set the package version for Python
working-directory: ./python
run: |
sed -i "s|255.255.255|${{ env.RELEASE_VERSION }}|g" ./Cargo.toml

- name: Build source distributions
uses: PyO3/maturin-action@v1
with:
working-directory: ./python
command: sdist
args: --out sdist

- name: Download binaries
uses: actions/download-artifact@v4
with:
path: python/wheels
merge-multiple: true

- name: Publish to PyPI
- name: Publish binaries and source to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.LIVEPYPI_API_TOKEN }}
MATURIN_REPOSITORY: pypi
with:
command: upload
args: --skip-existing python/wheels/*
args: --skip-existing python/wheels/* python/sdist/*

test-release:
if: github.event_name != 'pull_request'
name: Test the release
runs-on: ${{ matrix.build.RUNNER }}
needs: [publish-to-pypi, load-platform-matrix]
needs: [build-source-dist-and-publish-to-pypi, load-platform-matrix]
strategy:
fail-fast: false
matrix:
Expand Down
Loading