We already have a 'draft' pypi-publish.yml in the workflows. We need to edit it somewhat to make it work with tags, instead of making a release, since this seems easier with
on:
push:
tags:
'v*' # Triggers the workflow on any tag push starting with "v"
than with on: release.
We also might need a line for specific permissions:
packages: write # Write access is required to upload to PyPI
It might work also without, though.
Update also the 'actions' to their latest versions.
Then finally for the push-on-tag to work, the "Github Actions" must be edited by an admin to have the "Github Secrets" to have the secret:
secrets.PYPI_API_TOKEN
Python version specific wheels with build or one of the two?
A comparable publish file to ours is in https://github.com/2noise/ChatTTS/blob/main/.github/workflows/upload-pypi.yml. Taking inspiration from there, we replace the jobs: deploy with jobs: build. In the example, only a build is released, while our draft version was apparently either more towards uploading version-specific wheels. So which one should we do? Options are...
Wheels version
We can keep the strategy section with separate Python versions. We need to install also build so do pip install build twine wheel cibuildwheel and run cibuildwheel --output-dir wheelhouse. Change the upload line to python -m twine upload wheelhouse/*.whl. The extra arguments on this line do not seem to be necessary, so they can be removed.
Build and wheels
This is fairly the same as above, except the build line must be added: python -m build --sdist. And from the upload line described above, we need to add the dist folder dist/*.
Build-only
Now only one Python version is needed. The best is to use the 3.11. The strategy section can be removed and a new section added under steps:
The ${{ matrix.python-version }} "local variables" can be removed. As we don't make wheel, we need to install only pip install build twine. The Build wheel should get renamed as Build sdist and we use python -m build --sdist only.
For the upload we can drop again the extra arguments and use simply python -m twine upload dist/*.
Discussion
We need to choose which option to use. Decision:
The decision is to make a build AND a wheel, using the 3.11 python.
Instead of using cibuildwheel, install wheel with python -m pip install build wheel twine and
- name: Build the package (source distribution and wheel)
run: python -m build --sdist --wheel
and then upload with python -m twine upload dist/*
Description
We already have a 'draft'
pypi-publish.yml
in the workflows. We need to edit it somewhat to make it work with tags, instead of making a release, since this seems easier withon: push: tags:
than with on: release.
We also might need a line for specific permissions: packages: write # Write access is required to upload to PyPI It might work also without, though.
Update also the 'actions' to their latest versions.
Then finally for the push-on-tag to work, the "Github Actions" must be edited by an admin to have the "Github Secrets" to have the secret: secrets.PYPI_API_TOKEN
Python version specific wheels with build or one of the two?
A comparable publish file to ours is in https://github.com/2noise/ChatTTS/blob/main/.github/workflows/upload-pypi.yml. Taking inspiration from there, we replace the
jobs: deploy
withjobs: build
. In the example, only a build is released, while our draft version was apparently either more towards uploading version-specific wheels. So which one should we do? Options are...Wheels version
We can keep the
strategy
section with separate Python versions. We need to install alsobuild
so dopip install build twine wheel cibuildwheel
and runcibuildwheel --output-dir wheelhouse
. Change the upload line topython -m twine upload wheelhouse/*.whl
. The extra arguments on this line do not seem to be necessary, so they can be removed.Build and wheels
This is fairly the same as above, except the build line must be added:
python -m build --sdist
. And from the upload line described above, we need to add the dist folderdist/*
.Build-only
Now only one Python version is needed. The best is to use the 3.11. The
strategy
section can be removed and a new section added understeps
:The
${{ matrix.python-version }}
"local variables" can be removed. As we don't make wheel, we need to install onlypip install build twine
. TheBuild wheel
should get renamed asBuild sdist
and we usepython -m build --sdist
only.For the upload we can drop again the extra arguments and use simply
python -m twine upload dist/*
.Discussion
We need to choose which option to use. Decision:
cibuildwheel
, installwheel
withpython -m pip install build wheel twine
andand then upload with
python -m twine upload dist/*