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

GitHub action to automatically publish new releases to PyPi #448

Merged
merged 7 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# These workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be triggered manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I'm following, sorry :) Whenever you post a release in GitHub, the action gets triggered to build and upload it to PyPi. Unless you mean that the creation of a release itself is manual?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, I didn't know you'd have to post a release. Can you maybe update the documentation?

deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
- name: Build distribution
run: |
cd python/mlcroissant
python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
verify-metadata: true
skip-existing: true
packages-dir: python/mlcroissant/dist
repository-url: https://upload.pypi.org/legacy/
verbose: true
env:
LOGLEVEL: DEBUG

# If you wish to publish the package to multiple repositories at once, get inspiration from
# https://github.com/mlcommons/mlcube/blob/master/.github/workflows/python-publish.yml.
29 changes: 4 additions & 25 deletions python/mlcroissant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,10 @@ This will:
1. print extra information, like the generated nodes;
2. save the generated structure graph to a folder indicated in the logs.

## Publishing wheels
## Publishing packages

Publishing is done manually.
We are in the process of setting up an automatic deployment with GitHub Actions.
To publish a package,

1. Bump the version in `croissant/python/mlcroissant/pyproject.toml`.
1. Configure Twine locally ([full tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/)):
```
[distutils]
index-servers =
pypi
mlcroissant

[pypi]
username =
password =

[mlcroissant]
repository = https://upload.pypi.org/legacy/
username = __token__
password = # generate the password on https://pypi.org/manage/account/token/
```
1. Build locally and push to PyPI:
```bash
rm -rf dist/
python -m build
python -m twine upload --repository mlcroissant dist/*
```
2. Publish a release in GitHub. The workflow script `python-publish.yml` will trigger and publish the package to PyPI.

Loading