Package to PyPi #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package to PyPi | |
#on: | |
# release: | |
# types: [published] | |
on: workflow_dispatch | |
env: | |
WHL_HOUSE: wheelhouse | |
COMPILED_ARTS: compiled-artifacts | |
permissions: | |
contents: read | |
jobs: | |
build-sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
- name: make sdists | |
run: | | |
mkdir -p $WHL_HOUSE | |
python -m pip install build | |
python -m build --sdist --outdir $WHL_HOUSE . | |
ls ./$WHL_HOUSE # Listing the contents of ./$WHL_HOUSE for a sanity check | |
- name: Artifactize sdist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.COMPILED_ARTS }} | |
path: ${{ env.WHL_HOUSE }} | |
build-compiled-python-wheels: | |
# The manylinyux action (the following one) runs everything as root. So it | |
# is not predicatble how this interacts with other actions (e.g., it might | |
# create a directory accessible only for root so that subsequent actions | |
# cannot use it). | |
# Hence, it is very convenient to thave this action in a separate job | |
# and publish the outcome as artifacts. | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build permanentbis wheels | |
uses: pypa/cibuildwheel@v2.20.0 | |
env: | |
# We skip old versions of cPython, and all PyPy | |
# because we're not sure the C extension works on PyPy | |
CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-* pp*" | |
CIBW_BUILD_FRONTEND: "build" | |
with: | |
output-dir: '${{ env.WHL_HOUSE }}' | |
- name: Artifactize compiled-python wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.COMPILED_ARTS }}-${{ matrix.os }} | |
path: ${{ env.WHL_HOUSE }} | |
pypi-update: | |
needs: [build-compiled-python-wheels, build-sdist] | |
name: Publish to PyPI | |
environment: pypi-upload | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: ${{ env.WHL_HOUSE }} | |
merge-multiple: true | |
- name: Display structure of downloaded files | |
run: ls -R | |
working-directory: ${{ env.WHL_HOUSE }} | |
- name: Display all artifacts | |
run: ls -R | |
working-directory: ${{ env.WHL_HOUSE }} | |
#- name: Publish package to PyPI | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# packages-dir: ${{ env.WHL_HOUSE }}/ | |
# verbose: true |