Skip to content

Commit e9edaa7

Browse files
authored
GitHub action to automatically publish new releases to PyPi (#448)
Hi, Bruno Ferreira from MLCommons Systems here. This GitHub action should trigger whenever a new release is created and automatically build and publish the package to PyPi. The build commands use Twine to build the package.
1 parent b040b11 commit e9edaa7

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

.github/workflows/python-publish.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# These workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine build
25+
- name: Build distribution
26+
run: |
27+
cd python/mlcroissant
28+
python -m build
29+
- name: Publish
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
verify-metadata: true
33+
skip-existing: true
34+
packages-dir: python/mlcroissant/dist
35+
repository-url: https://upload.pypi.org/legacy/
36+
verbose: true
37+
env:
38+
LOGLEVEL: DEBUG
39+
40+
# If you wish to publish the package to multiple repositories at once, get inspiration from
41+
# https://github.com/mlcommons/mlcube/blob/master/.github/workflows/python-publish.yml.

python/mlcroissant/README.md

+4-25
Original file line numberDiff line numberDiff line change
@@ -132,31 +132,10 @@ This will:
132132
1. print extra information, like the generated nodes;
133133
2. save the generated structure graph to a folder indicated in the logs.
134134

135-
## Publishing wheels
135+
## Publishing packages
136136

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

140139
1. Bump the version in `croissant/python/mlcroissant/pyproject.toml`.
141-
1. Configure Twine locally ([full tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/)):
142-
```
143-
[distutils]
144-
index-servers =
145-
pypi
146-
mlcroissant
147-
148-
[pypi]
149-
username =
150-
password =
151-
152-
[mlcroissant]
153-
repository = https://upload.pypi.org/legacy/
154-
username = __token__
155-
password = # generate the password on https://pypi.org/manage/account/token/
156-
```
157-
1. Build locally and push to PyPI:
158-
```bash
159-
rm -rf dist/
160-
python -m build
161-
python -m twine upload --repository mlcroissant dist/*
162-
```
140+
2. Publish a release in GitHub. The workflow script `python-publish.yml` will trigger and publish the package to PyPI.
141+

0 commit comments

Comments
 (0)