The issues with publishing the documentation upon opening a pull request or merging a pull request into main are that those don't necessarily correlate with a publication to PyPi, meaning the live documentation may not be finalized or it might reflect a later release that has not made its way to PyPi yet. One option to control when the documentation gets published is to use workflow_dispatch. However, it might be possible to do so using GitHub releases.
While I still need to work out the details (including determining if this is even possible), I envision that we could have a GitHub action that's triggered by a release that would:
Follow these steps to create a new release and associated tag.
The release should trigger a deployment that does the following.
Build the package via python -m build
Run twine check dist/*
Publish the package to testpypi
We'll need testpypi credentials for this. We can possibly get them using GitHub actions
We may want to use organization secrets so that the same credentials can be used across all projects, reducing the amount of configuration done by the developer.
If the individual developer needs access to manage the PyPi package, then the owner of MoseleyBioinformaticsLab may need to add the developer as an owner rather than the developer adding MoseleyBioinformaticsLab as an owner.
If publishing to testpypi succeeds, pip install the testpypi package
Using the installed package, run the tests (on all 3 operating systems as usual).
If the tests succeed, uninstall the testpypi package and publish the real version of the package.
This will require PyPi credentials in the same way as for testpypi
As an extra precaution, install the real version of the package from PyPi and run the tests on the real package.
Build the documentation corresponding to the version tag of the release (should be same as for PyPi.
Publish the documention to GitHub pages.
We could have a separate .yml file for the documentation and the PyPi / tests. We may want to further re-use actions for running the tests since there is already an action that runs tests that's ran during a pull request. We can have the following:
tests.yml
documentation.yml (not triggered, only used by package_release.yml
package_release.yml re-uses tests.yml (maybe) and documentation.yml
It might be necessary to have an additional .yml file that re-uses tests.yml since when submitting a pull request, we may not only run tests but we also install the package and we do so in a different way than we would in the pypi.yml.
It may be better to use the 0.x.x version when prototyping with testpypi since the first couple of attempts may not work.
This tutorial could be helpful. Looks like we'll want to use the PyPi API token.
The issues with publishing the documentation upon opening a pull request or merging a pull request into main are that those don't necessarily correlate with a publication to PyPi, meaning the live documentation may not be finalized or it might reflect a later release that has not made its way to PyPi yet. One option to control when the documentation gets published is to use
workflow_dispatch
. However, it might be possible to do so using GitHub releases.While I still need to work out the details (including determining if this is even possible), I envision that we could have a GitHub action that's triggered by a release that would:
python -m build
twine check dist/*
pip install
the testpypi packageWe could have a separate
.yml
file for the documentation and the PyPi / tests. We may want to further re-use actions for running the tests since there is already an action that runs tests that's ran during a pull request. We can have the following:tests.yml
documentation.yml
(not triggered, only used bypackage_release.yml
package_release.yml
re-uses tests.yml (maybe) anddocumentation.yml
It might be necessary to have an additional
.yml
file that re-usestests.yml
since when submitting a pull request, we may not only run tests but we also install the package and we do so in a different way than we would in thepypi.yml
.It may be better to use the 0.x.x version when prototyping with testpypi since the first couple of attempts may not work.
This tutorial could be helpful. Looks like we'll want to use the PyPi API token.