From e381b6263c2951920d1ccf2c8140b7d4c58ecc00 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Thu, 25 Dec 2025 20:15:19 +0800 Subject: [PATCH] ci: include source distributions in PyPI uploads. Description This PR updates the GitHub Actions workflows to ensure that source distributions (sdist) are built and uploaded to PyPI alongside the wheels. This allows users to install the packages from source when a compatible wheel is not available for their platform. Changes: - `pytest.yml` (apyds): - Added a new sdist job to build the source distribution using uv build --sdist. - Updated the upload job to wait for and download both wheels and the source distribution before publishing. - `bnf-pytest.yml` (apyds-bnf): - Updated the artifact upload step to include the entire dist/ directory (containing both .whl and .tar.gz files generated by uv build). - `egg-pytest.yml` (apyds-egg): - Updated the artifact upload step to include the entire dist/ directory. --- .github/workflows/bnf-pytest.yml | 2 +- .github/workflows/egg-pytest.yml | 2 +- .github/workflows/pytest.yml | 32 +++++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bnf-pytest.yml b/.github/workflows/bnf-pytest.yml index 2cc8a9f..0843b99 100644 --- a/.github/workflows/bnf-pytest.yml +++ b/.github/workflows/bnf-pytest.yml @@ -64,7 +64,7 @@ jobs: - uses: actions/upload-artifact@v6 with: name: dist - path: bnf/dist/*.whl + path: bnf/dist/ upload: runs-on: ubuntu-latest diff --git a/.github/workflows/egg-pytest.yml b/.github/workflows/egg-pytest.yml index 887722a..2b7b77d 100644 --- a/.github/workflows/egg-pytest.yml +++ b/.github/workflows/egg-pytest.yml @@ -58,7 +58,7 @@ jobs: - uses: actions/upload-artifact@v6 with: name: dist - path: egg/dist/*.whl + path: egg/dist/ upload: runs-on: ubuntu-latest diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index d0f8ba8..e839809 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -65,9 +65,34 @@ jobs: name: wheels-${{ matrix.os }} path: wheelhouse/*.whl + sdist: + runs-on: ubuntu-latest + needs: pytest + + if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags')" + + steps: + - uses: actions/checkout@v6 + + - name: recovery tag information + run: git fetch --tags --force + + - uses: astral-sh/setup-uv@v7 + with: + python-version: ${{ env.PYTHON_LATEST_VERSION }} + enable-cache: true + + - name: build sdist + run: uv build --sdist + + - uses: actions/upload-artifact@v6 + with: + name: sdist + path: dist/*.tar.gz + upload: runs-on: ubuntu-latest - needs: wheels + needs: [wheels, sdist] environment: name: pypi @@ -82,6 +107,11 @@ jobs: path: dist merge-multiple: true + - uses: actions/download-artifact@v7 + with: + name: sdist + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist