Skip to content

Commit

Permalink
Add source distribution upload to the PyPi-CD workflow (#3213)
Browse files Browse the repository at this point in the history
* updated pypi-cd to publish and test source distribution

Signed-off-by: lior sventitzky <[email protected]
  • Loading branch information
liorsve authored Feb 23, 2025
1 parent 0ab859e commit 3789f14
Showing 1 changed file with 30 additions and 5 deletions.
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:
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

0 comments on commit 3789f14

Please sign in to comment.