QuTech-Delft / QMI

Quantum Measurement Infrastructure
Other
14 stars 4 forks source link

Update pypi-publish.yml to create and upload package with tags #100

Closed heevasti closed 3 weeks ago

heevasti commented 1 month ago

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 with

on: 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 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:

      uses: actions/setup-python@v4
      with:
        python-version: '3.11'

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: