diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 8a8aece..dcb1bd7 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.4.2 +current_version = 0.4.3 commit = True tag = True diff --git a/README.md b/README.md index 20299f0..782ff5c 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,19 @@ python -m build ## Release process -* Update version in `pyproject.toml` and `src/lionweb/__init__.py` -* Create tag: `git tag -a v0.1.1 -m "Version 0.1.1"` -* Release on PyPI: - -``` -pip install setuptools wheel twine -python setup.py sdist bdist_wheel -twine upload dist/* -``` -* Push tag +Releases are published to PyPI from a local machine with `release.sh`. + +1. Install the release tools: `pip install bump2version build twine`, and configure + your PyPI credentials in `~/.pypirc`. +2. On `main`, move the entries of the upcoming version into their section in + `CHANGELOG.md`, commit and push. +3. Run `./release.sh` (or `./release.sh minor` / `./release.sh major`). + +The script checks that you are on a clean `main` in sync with `origin/main`, then: + +* bumps the version in `src/lionweb/__init__.py` (the only place it is written; + `pyproject.toml` reads it from there) and in `.bumpversion.cfg`, committing the + change and creating the `vX.Y.Z` tag +* builds the sdist and wheel into `dist/` +* pushes `main` and the tag +* uploads the package to PyPI diff --git a/release.sh b/release.sh index 3ea02d6..ee25a17 100755 --- a/release.sh +++ b/release.sh @@ -1,17 +1,38 @@ #!/bin/bash +# Publishes a new release to PyPI. See "Release process" in README.md. +# Usage: ./release.sh [patch|minor|major] (default: patch) -set -e # Stop on errors +set -euo pipefail -# Bump version -bump2version patch # Change to minor or major if needed +PART="${1:-patch}" +case "$PART" in + patch|minor|major) ;; + *) echo "Usage: $0 [patch|minor|major]" >&2; exit 1 ;; +esac -# Push changes -git push origin --tags +# Only release an up-to-date, clean main +if [ "$(git branch --show-current)" != "main" ]; then + echo "Releases must be made from main" >&2; exit 1 +fi +if [ -n "$(git status --porcelain --untracked-files=no)" ]; then + echo "There are uncommitted changes" >&2; exit 1 +fi +git fetch origin main --tags +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then + echo "Local main is not in sync with origin/main" >&2; exit 1 +fi -rm -Rf dist +# Bump version: commits and creates the vX.Y.Z tag +bump2version "$PART" +VERSION=$(sed -n 's/^current_version = //p' .bumpversion.cfg) # Build the package +rm -Rf dist python -m build +twine check dist/* + +# Push the bump commit and the tag +git push origin main "v$VERSION" # Upload to PyPI -twine upload --repository custom-pypi --config-file ~/.pypirc --non-interactive dist/* +twine upload --config-file ~/.pypirc --non-interactive dist/* diff --git a/src/lionweb/__init__.py b/src/lionweb/__init__.py index 657f5bb..739ab8d 100644 --- a/src/lionweb/__init__.py +++ b/src/lionweb/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.4.2" +__version__ = "0.4.3" from .lionweb_version import LionWebVersion __all__ = ["LionWebVersion"]