Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create python-publish.yml #249

Closed
wants to merge 1 commit into from
Closed

Conversation

richardjgowers
Copy link
Contributor

Fixes #247

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f87e236) 99.18% compared to head (e376601) 99.18%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #249   +/-   ##
=======================================
  Coverage   99.18%   99.18%           
=======================================
  Files          36       36           
  Lines        1843     1843           
=======================================
  Hits         1828     1828           
  Misses         15       15           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something I wasn't sure on, should this just use the same micromamba checkout we use for CI? Or is this good enough for package building?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're building python wheels for pypi I'd got pure Python - so this route

uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the recommend way to do this is to use OIDC now, so you don't use the token/user and just make it a trusted workflow on pypi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip versioningit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not need this, this is pulled in by build_requires

- name: Install dependencies
run: |
python -m pip install --upgrade pip versioningit
pip install build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just install pipx here and run pipx run build below, env isolation can be nice to make sure you didn't pull anything weird earlier (you shouldn't but I get really skeptical of github python setup actions).

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uses: actions/setup-python@v3
uses: actions/setup-python@v4

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v3
- uses: actions/checkout@v4

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're building python wheels for pypi I'd got pure Python - so this route

- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not pin to a specific release version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just clicked the action button and it gave me this

name: Upload Python Package

on:
release:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to also do a testpypi release on tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd only do it so you can save yourself a bugfix push, it's fine if you don't mess with packaging too often though.

I would however recommend that you do pull down the package and run tests post deploy though - that way you don't have to think about "will it work".

I wrote a re-usable action for this here: https://github.com/MDAnalysis/pypi-deployment/tree/main

You can see an example of it here: https://github.com/MDAnalysis/MDAnalysisData/blob/master/.github/workflows/deploy.yaml

(you can remove the test deployment if you don't want it).

Advantage of the re-usable action is that you only have to update a single place and everything will keep working.

@richardjgowers richardjgowers deleted the richardjgowers-patch-1 branch January 19, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate the PyPi release of gufe?
2 participants