Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Adds first PyPI publishing workflow #51

Merged
merged 30 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c94efd9
testing pypi release test
binaryaaron Feb 13, 2024
b33d10c
adding tag filter for events
binaryaaron Feb 13, 2024
b837099
updated tag matching regex
binaryaaron Feb 13, 2024
51ec605
added poetry installation steps
binaryaaron Feb 13, 2024
629fa95
changed to pipe for multiple line breaks
binaryaaron Feb 13, 2024
4c3e158
added extra checkout
binaryaaron Feb 14, 2024
420511f
changed env var name
binaryaaron Feb 14, 2024
f380cdd
corrected org secret name
binaryaaron Feb 14, 2024
f8faee8
updated rc version
binaryaaron Feb 14, 2024
0ea14b2
adding gh release uploader and bumping rc version
binaryaaron Feb 14, 2024
57d7745
updating workflows
binaryaaron Feb 14, 2024
ec32585
updating workflow with better steps
binaryaaron Feb 14, 2024
3ed90bc
removing github release publisher for testing
binaryaaron Feb 14, 2024
314dee2
adding output env vars
binaryaaron Feb 14, 2024
e2c0891
test
binaryaaron Feb 14, 2024
0f8becb
removing env var ref
binaryaaron Feb 14, 2024
14a0226
remove dist check
binaryaaron Feb 14, 2024
947f3c9
sourcing venv each step
binaryaaron Feb 14, 2024
10a28ea
testing gh release
binaryaaron Feb 14, 2024
7d95443
bumping rc version
binaryaaron Feb 14, 2024
baa1977
removed conditional for draft release
binaryaaron Feb 14, 2024
f8fcf66
bumping rc version
binaryaaron Feb 14, 2024
9678450
updating download ref
binaryaaron Feb 14, 2024
09aec53
testing artifact names
binaryaaron Feb 14, 2024
eaa41e0
adding back in artifact names
binaryaaron Feb 14, 2024
cb5067f
Update .github/workflows/publish.yaml
binaryaaron Feb 14, 2024
075d2e0
Update .github/workflows/publish.yaml
binaryaaron Feb 14, 2024
af0e4ca
typos / corrections
binaryaaron Feb 14, 2024
4fed54d
Merge branch 'main' into agonzales/publish-pypi
binaryaaron Feb 14, 2024
aba58c0
adding contributor docs
binaryaaron Feb 14, 2024
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
91 changes: 91 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Build and publish to PyPI
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Build and publish to PyPI
name: Build and publish to PyPI

Should name the workflow a as a whole, or else it displays weird in the PR checks


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/*
48 changes: 45 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
`.github/workflows/publish.yaml' contains the GitHub Action used to do releases and push wheels to PyPI.
`.github/workflows/publish.yaml` contains the GitHub Action used to do releases and push wheels to PyPI.

Ticks were off, so was not displaying code style


There are two subcases - draft/dev and the 'real' release.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
There are two subcases - draft/dev and the 'real' release.
There are two cases - 'draft' and the 'real' releases.



### Draft / Test releases
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Draft / Test releases
### Draft releases


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:
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
If a contributer opens a PR to `main` with a git version tag (e.g., `vX.Y.Z`) , the draft process will start which does the following:


- upload a version to test PyPI
- make a draft release on github.


this is to ensure the full process works before merging to main.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this is to ensure the full process works before merging to main.
This is to ensure the full process works before merging to `main`.



### Real release
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Real release
### Real releases


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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "lm-buddy"
version = "0.1.0"
version = "0.1.0rc12"
description = "Ray-centric library for finetuning and evaluation of (large) language models."
repository = "https://github.com/mozilla-ai/lm-buddy"
readme = "README.md"
Expand Down
Loading