Browse Source

add mkrelease utility for mostly automated releasing

Can't be bothered reading up on the GitHub release API, assuming it
exists, for now.
pull/675/head
Melvin Vermeeren 1 year ago
parent
commit
011c714cad
No known key found for this signature in database
GPG Key ID: A72F627716EA9D96
  1. 8
      README.rst
  2. 121
      mkrelease

8
README.rst

@ -119,13 +119,7 @@ link in a GitHub issue.
Release
-------
Commands for releasing source bundle & wheel to PyPI::
python setup.py sdist bdist_wheel
cd dist
# Verify files are file manually.
for i in *; do gpg -ba -- "$i"; done
twine upload *
See the mkrelease utility in the root of the repository.
Credits
-------

121
mkrelease

@ -0,0 +1,121 @@
#!/bin/sh
set -eu
hash cd
hash git
hash gpg
hash mkdir
hash printf
hash python3
hash rm
hash tar
hash twine
# Melvin Vermeeren <vermeeren@vermwa.re>
PGP_KEY='8AED 5802 1FEA CDD5 F27B A0E6 A72F 6277 16EA 9D96'
REPO_WWW='https://github.com/michaeljones/breathe'
help()
{
printf 'Usage: %s pack\n' "$0"
printf 'Usage: %s sign\n' "$0"
printf 'Usage: %s upload\n' "$0"
printf 'Usage: %s clean\n' "$0"
return 0
}
pack()
(
mkdir -- mkrelease_tmp
git archive \
--format=tar.gz \
--prefix="breathe-$version/" \
-o "mkrelease_tmp/breathe-$version.tar.gz" \
-- "v$version" \
cd -- mkrelease_tmp
tar -xf "breathe-$version.tar.gz"
cd -- "breathe-$version"
python3 setup.py sdist bdist_wheel
mv -- dist ..
cd -- ..
rm -r -- "breathe-$version"
exit 0
)
sign()
(
cd -- mkrelease_tmp
gpg -bu "$PGP_KEY" -- "breathe-$version.tar.gz"
for file in dist/*; do
gpg -bau "$PGP_KEY" -- "$file"
done
exit 0
)
upload()
(
cd -- mkrelease_tmp
twine upload -- dist/*
{
printf 'Note: Source tarball signature must be uploaded manually.\n'
printf '\tCreate a new release on GitHub for version: %s\n' "$version"
printf '\tThe source tarball itself must not be uploaded.\n'
printf '\t%s\n' "$REPO_WWW/releases/new?tag=v$version"
} >&2
exit 0
)
clean()
(
if [ -d mkrelease_tmp ]; then
rm -r -- mkrelease_tmp
fi
exit 0
)
if [ "$#" -eq 0 ]; then
help >&2
exit 1
fi
if [ ! -d .git ]; then
printf 'Error: Not executed from repository root\n' >&2
exit 1
fi
if ! version="$(git describe --tags --exact)"; then
printf 'Error: Cannot retrieve version from git.\n' >&2
exit 1
fi
version="${version#v}"
command="$1"
case "$command" in
pack|sign|upload|clean)
"$command"
;;
*)
{
printf 'Error: Unknown command: %s\n' "$command"
printf '\n'
help
} >&2
exit 1
esac
exit 0
Loading…
Cancel
Save