-
Notifications
You must be signed in to change notification settings - Fork 3
Adds first PyPI publishing workflow #51
Changes from all commits
c94efd9
b33d10c
b837099
51ec605
629fa95
4c3e158
420511f
f380cdd
f8faee8
0ea14b2
57d7745
ec32585
3ed90bc
314dee2
e2c0891
0f8becb
14a0226
947f3c9
10a28ea
7d95443
baa1977
f8fcf66
9678450
09aec53
eaa41e0
cb5067f
075d2e0
af0e4ca
4fed54d
aba58c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Build and publish to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- "main" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build_dist: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: set up python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: set up poetry | ||
id: setup | ||
run: | | ||
export VENV_PATH="$HOME/venv" | ||
python3 -m venv $VENV_PATH | ||
source "$VENV_PATH/bin/activate" | ||
pip install -U pip setuptools | ||
pip install poetry | ||
poetry config repositories.testpypi https://test.pypi.org/legacy/ | ||
poetry build | ||
|
||
- name: Archive Production Artifact | ||
uses: actions/upload-artifact@v4 | ||
id: lmbuddy_artifacts | ||
with: | ||
name: lmbuddy_dists | ||
path: dist/ | ||
retention-days: 1 | ||
|
||
- name: Publish dist to test pypi | ||
env: | ||
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.PYPI_TEST_KEY }} | ||
|
||
if: ${{ github.event_name == 'pull_request' }} | ||
run: | | ||
source "$HOME/venv/bin/activate" | ||
cd $GITHUB_WORKSPACE | ||
echo "$GITHUB_WORKSPACE" | ||
which poetry | ||
poetry publish --repository testpypi | ||
|
||
- name: Publish dist to real pypi | ||
env: | ||
POETRY_PYPI_TOKEN: ${{ secrets.PYPI_KEY }} | ||
# only runs full release if we're on main; tag filter already hit above | ||
if: endsWith(github.event.base_ref, 'main') == true | ||
run: | | ||
source "$HOME/venv/bin/activate" | ||
poetry publish | ||
|
||
github-release: | ||
name: Prepare release | ||
needs: | ||
- build_dist | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: lmbuddy_dists | ||
path: ./dist/ | ||
merge-multiple: true | ||
|
||
- name: Release Draft | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: ./dist/* | ||
draft: true | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
# only runs full release if we're on main; tag filter already hit above | ||
if: endsWith(github.event.base_ref, 'main') == true | ||
with: | ||
files: ./dist/* |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -80,7 +80,7 @@ For a full sample job with a directory structure that you can run with a simple | |||||
[run locally to submit to the Job Submission SDK](https://docs.ray.io/en/latest/cluster/running-applications/job-submission/sdk.html#submitting-a-ray-job), | ||||||
see the `examples/dev_submission` directory. | ||||||
|
||||||
## Publishing | ||||||
## Publishing (manual) | ||||||
|
||||||
This section is intended for only maintainers at Mozilla.ai. | ||||||
Use the local installable package workflow above for iteration locally. | ||||||
|
@@ -95,10 +95,11 @@ Set up poetry to use the key(s): | |||||
|
||||||
``` | ||||||
poetry config repositories.testpypi https://test.pypi.org/legacy/ | ||||||
poetry config pypi-token.testpypi $(op read "op://<VAULT>/PyPI-test/pypi/api_key") | ||||||
poetry config pypi-token.pypi $(op read "op://<VAULT>/PyPI/pypi/api_key") | ||||||
poetry config pypi-token.testpypi $(op read "op://mzai-dev/PyPI-test/pypi/api_key") | ||||||
poetry config pypi-token.pypi $(op read "op://mzai-dev/PyPI/pypi/api_key") | ||||||
``` | ||||||
|
||||||
|
||||||
### Testing publishing | ||||||
|
||||||
Then build and publish to PyPI Test: | ||||||
|
@@ -115,3 +116,44 @@ When you're ready, run: | |||||
``` | ||||||
poetry publish --build | ||||||
``` | ||||||
|
||||||
## Publishing (automated) | ||||||
|
||||||
`.github/workflows/publish.yaml' contains the GitHub Action used to do releases and push wheels to PyPI. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Ticks were off, so was not displaying code style |
||||||
|
||||||
There are two subcases - draft/dev and the 'real' release. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
### Draft / Test releases | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
If a contributed opens a PR to `main` with a git version tag (e.g., `vX.Y.Z`) , the draft process will start which does the following: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
- upload a version to test PyPI | ||||||
- make a draft release on github. | ||||||
|
||||||
|
||||||
this is to ensure the full process works before merging to main. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
### Real release | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
If a commit is made to `main` with a git version tag (e.g., `vX.Y.Z`), the full process will run, and upload the package to PyPI and make a formal Release. | ||||||
|
||||||
|
||||||
The workflow should look like the following: | ||||||
|
||||||
- make your changes that will be included in a release (could be a long running dev branch or otherwise) | ||||||
- update the version in `pyproject.toml` | ||||||
- add an annotated tag, e.g.: | ||||||
* `git tag -a v1.4.0 -m "1.4.0 prepped for release; see ___ for changes"` or | ||||||
* `git tag -a v1.4.3 -m "1.4.3 is a patch for issue ____"` | ||||||
- push your changes to upstream | ||||||
- open a PR to main | ||||||
- verify that the project builds | ||||||
- land PR | ||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
Comment on lines
+155
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should name the workflow a as a whole, or else it displays weird in the PR checks