Created
March 19, 2023 17:07
-
-
Save wosc/ac57aa8a3cbee4b0501237ef2852cc55 to your computer and use it in GitHub Desktop.
Release dance for a python package with hatch
This file contains hidden or 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
#!/bin/bash | |
# Generic "Bump version, update changelog, git tag, upload to pypi, bump version" workflow, | |
# like zest.releaser+setuptools, but for hatch+towncrier | |
# Matching pyproject.toml example: https://github.com/wosc/nginx-db-auth/blob/1.1.0/pyproject.toml | |
# (the salient points are 1) `hatch run release:towncrier`, 2) `dynamic = ["version"]`, 3) file locations for changelog and version) | |
set -ex | |
changelog=$(hatch run release:towncrier build --version=draft --draft 2>&1) | |
if echo "$changelog" | grep -q "No significant changes"; then | |
echo "No changelog entries exist that could be released" | |
exit 1 | |
fi | |
hatch version release | |
version=$(hatch version) | |
hatch run release:towncrier build --version="$version" --yes | |
git commit src/**/__init__.py CHANGES.txt changelog/ -m "Preparing release: $version" | |
git tag "$version" | |
hatch build | |
hatch publish --user __token__ --auth "$(pass show tokens/pypi)" | |
hatch version minor | |
hatch version dev | |
git commit src/**/__init__.py -m "Back to development: $(hatch version)" | |
rm -rf dist | |
git push | |
git push --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment