From 03ec4b8e666e459179dbbf1ddf1f525598926a9e Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Wed, 9 Oct 2024 10:54:33 +0200 Subject: [PATCH] update wheels and sdits building and distribution --- .github/workflows/ci.yml | 126 ++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce18199..101855d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,16 +56,43 @@ jobs: name: ${{ matrix.python }} fail_ci_if_error: false - build_wheels: - needs: [tests] + source_distribution: if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' - name: ${{ matrix.os }} + needs: + - tests + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + name: Install Python + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install build + + - name: Build a source tarball + run: python -m build + + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/*.tar.gz + + wheels: + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' + needs: + - tests + name: Build wheels for ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-2019, macos-latest] - steps: - uses: actions/checkout@v4 @@ -86,45 +113,74 @@ jobs: - uses: actions/upload-artifact@v4 with: - path: ./wheelhouse - overwrite: true + name: wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl - build_sdist: - needs: [tests] + publish-to-pypi: if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' - name: Build source distribution + needs: + - source_distribution + - wheels + name: Upload Source and Wheels to Pypi runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/color-operations + permissions: + id-token: write steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - name: Install Python + - name: Download all the dists + uses: actions/download-artifact@v4 with: - python-version: '3.10' - - - name: Install dependencies - run: | - python -m pip install numpy Cython - - - name: Build sdist - run: python setup.py sdist + name: python-package-distributions + path: dist/ + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest - - uses: actions/upload-artifact@v4 - with: - path: dist/*.tar.gz - overwrite: true + permissions: + contents: write + id-token: write - upload_pypi: - needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v4 + - name: Download all the dists + uses: actions/download-artifact@v4 with: - name: artifact - path: dist + name: python-package-distributions + path: dist/ - - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v2.1.1 with: - user: ${{ secrets.PYPI_USERNAME }} - password: ${{ secrets.PYPI_PASSWORD }} - # To test: repository_url: https://test.pypi.org/legacy/ + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' +