uclahs-cds / package-moPepGen

Multi-Omics Peptide Generator
https://uclahs-cds.github.io/package-moPepGen/
GNU General Public License v2.0
6 stars 1 forks source link

Add GitHub action to publish to PyPI #865

Closed zhuchcn closed 7 months ago

zhuchcn commented 7 months ago

Description

Closes #...

Checklist

zhuchcn commented 7 months ago

@aholmes I tested it locally to push it to test-PyPI and it does work (https://test.pypi.org/project/mopepgen/). Installed it from test-PyPI and verified that the "test" directory isn't installed as a module. This workflow runs on tags, and it recognizes the version from setup.cfg directly. How should we test the action on test-PyPI? If we make a tag on the latest commit, it will still be published to test-PyPI as the current version number v1.3.2. Also, if I push a tag on the latest commit on this branch, will the action be triggered even when the main branch doesn't have the action yet?

zhuchcn commented 7 months ago

Seems like once the PyPI project is already created, I can't add a github action to it. The 'Add a new pending publisher' only works for project not exist on PyPI yet. Seems like we can provide a PyPI API token to the action. But for the actual PyPI, we should be able to use the 'Add a new pending publisher' function directly without token.

aholmes commented 7 months ago

How should we test the action on test-PyPI? If we make a tag on the latest commit, it will still be published to test-PyPI as the current version number v1.3.2.

Take a look at this PR to get a sense of the steps I took in making this work for BL_Python.

During my final testing on test.pypi, I committed fake version bumps (to main it looks like, though I'm not sure that was necessary) and then pushed fake tags. For example, here I altered the version of BL_Python.web to 0.0.1-16. I later reverted this when my testing was done.

You can see all my test version bumps published on test.pypi. I don't recall exactly where the "post" part comes from - it might be automatic on PyPI's part?

Also, if I push a tag on the latest commit on this branch, will the action be triggered even when the main branch doesn't have the action yet?

No - actions are only triggered if the workflow file exists in the default branch. However, that workflow file can be empty and do nothing; it only has to exist. Once that's done, any branch should be able to trigger workflows from that file in that branch.

aholmes commented 7 months ago

Seems like once the PyPI project is already created, I can't add a github action to it. The 'Add a new pending publisher' only works for project not exist on PyPI yet. Seems like we can provide a PyPI API token to the action. But for the actual PyPI, we should be able to use the 'Add a new pending publisher' function directly without token.

What steps did you take, and what failed where and when?

zhuchcn commented 7 months ago

So seems like we can first merge this to main, and then I can change the version to a random number, and push a tag to the branch to trigger the workflow? I won't commit version change to main so we don't have to revert.

I think I just successfully connected this repo to the project in test pypi so we can give it a try now.

aholmes commented 7 months ago

So seems like we can first merge this to main, and then I can change the version to a random number, and push a tag to the branch to trigger the workflow?

Yep, that should do it.

zhuchcn commented 7 months ago

v0.0.2 successfully pushed to test.pypi!