-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from ekiefl/streamline-publishing
Streamline publishing
- Loading branch information
Showing
13 changed files
with
1,316 additions
and
700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: test | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.12"] | ||
poetry-version: ["1.8.3"] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: ${{ matrix.poetry-version }} | ||
- name: Setup a local virtual environment | ||
run: | | ||
poetry config virtualenvs.create true --local | ||
poetry config virtualenvs.in-project true --local | ||
- uses: actions/cache@v3 | ||
name: Define a cache for the virtual environment based on the dependencies lock file | ||
with: | ||
path: ./.venv | ||
key: venv-${{ hashFiles('poetry.lock') }} | ||
- name: Install project dependencies | ||
run: poetry install | ||
- name: Run tests | ||
run: poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
include .env | ||
|
||
# Note: `poetry` does not appear to read the `POETRY_PYPI_TOKEN_<NAME>` environment variable, | ||
# so we need to pass it explicitly in the `publish` command. | ||
.PHONY: test-publish | ||
test-publish: | ||
echo ${POETRY_PYPI_TOKEN_PYPI_TEST} | ||
poetry publish \ | ||
--repository pypi-test \ | ||
--username __token__ \ | ||
--password ${POETRY_PYPI_TOKEN_PYPI_TEST} | ||
|
||
.PHONY: publish | ||
publish: build | ||
poetry publish \ | ||
--username __token__ \ | ||
--password ${POETRY_PYPI_TOKEN_PYPI} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Publishing a new pooltool release | ||
|
||
These are instructions for how to make new pip-installable pooltool versions on PyPi. | ||
|
||
## 1. House keeping | ||
|
||
- Update `logo.png` if its not a sub-version (rename logo_small.png to previous version (e.g. logo_v0p1.png) open Blender file, update textures, render at top, save as logo.png). Then make a copy of logo.png that is 640 x 360 called logo_small.png. | ||
|
||
## 2. Create a git tag | ||
|
||
Versioning is handled dynamically based on git tags. So to make a new release, you first make a new git tag. Make sure you're on the main branch with no uncommitted changes. | ||
|
||
```bash | ||
RELEASE_VERSION=0.1.0 | ||
git tag -a v${RELEASE_VERSION} -m "Release version ${RELEASE_VERSION}" | ||
git push origin v${RELEASE_VERSION} | ||
``` | ||
|
||
If you need to delete a tag you've created (or even pushed), use: | ||
|
||
```bash | ||
git tag -d <tagname> # Locally delete | ||
git push origin :refs/tags/<tagname> # If you pushed it | ||
``` | ||
|
||
## 3. Build the distribution | ||
|
||
```bash | ||
poetry build | ||
``` | ||
|
||
You should see something like this: | ||
|
||
```bash | ||
Building pooltool-billiards (0.1.0) | ||
- Building sdist | ||
- Built pooltool_billiards-0.1.0.tar.gz | ||
- Building wheel | ||
- Built pooltool_billiards-0.1.0-py3-none-any.whl | ||
``` | ||
|
||
If there are additional metadata attached to the version (_e.g._ `0.3.4a2.dev1+eb17e9c.dirty`), then your tag isn't up to date. | ||
|
||
Open the tar found in `dist/`. If you've added any non-Python files to the package since the last release, make sure they are either present or absent from the package (depending on the desired outcome). | ||
|
||
Also open `pooltool/__init__.py` and make sure the `__version__` variable was populated with something other than the placeholder, `0.0.0`. | ||
|
||
## 4. Publish to the **test** PyPI repository | ||
|
||
- Populate your `.env` using `.env.copy` as a template. | ||
|
||
- Run `make test-publish`. If this fails due to timing out (slow upload speed that gets cut short), skip ahead to trying out the installation locally. | ||
|
||
- Create a fresh python environment to test the installation | ||
|
||
``` | ||
source ~/.bashrc | ||
conda deactivate | ||
conda env remove --name asdf | ||
conda create -y -n asdf python=3.8.10 | ||
PYTHONPATH="" | ||
conda activate asdf | ||
``` | ||
|
||
- Install: | ||
|
||
```bash | ||
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple --extra-index-url https://archive.panda3d.org/ pooltool-billiards==${RELEASE_VERSION} --force-reinstall | ||
``` | ||
|
||
If test PyPi is timing out, you can instead consider testing the installation with | ||
|
||
```bash | ||
pip install dist/pooltool_billiards-${RELEASE_VERSION}.tar.gz --force-reinstall --extra-index-url https://archive.panda3d.org/ | ||
``` | ||
|
||
- Test it out. Make sure `which run-pooltool` leads to the asdf environment: `/Users/evan/anaconda3/envs/asdf/bin/run_pooltool`. Then see if the interactive interface can be loaded: `run-pooltool`. Additionally, check the path of `cd ~; python -c "import pooltool; print(pooltool.__file__)"; cd -`. It should be in site-packages of asdf environment. | ||
|
||
## 5. Publish to the **real** PyPI repository | ||
|
||
- Go back to the dev environment. | ||
|
||
- Run `make publish` | ||
|
||
- Create a new python environment | ||
|
||
``` | ||
source ~/.bashrc | ||
conda deactivate | ||
conda env remove --name asdf | ||
conda create -y -n asdf python=3.8.10 | ||
PYTHONPATH="" | ||
conda activate asdf | ||
cd ~ | ||
``` | ||
|
||
- Test installation: `pip install pooltool-billiards==${RELEASE_VERSION}` (you may need to wait for version to be live) | ||
|
||
## 6. Make a release | ||
|
||
- Make a release on github from the tag. Upload the `.whl` and `.tar.gz` found in `dist/`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ channels: | |
- defaults | ||
- conda-forge | ||
dependencies: | ||
- python==3.8.10 | ||
- python==3.12.4 | ||
- pip | ||
- pip: | ||
- poetry>=1.8.3 |
Oops, something went wrong.