Skip to content

Commit

Permalink
Merge pull request #46 from meejah/release-machinery
Browse files Browse the repository at this point in the history
Release 0.5.0, plus automation for releases
  • Loading branch information
meejah authored Nov 7, 2024
2 parents 30ecb6e + ba274f1 commit fec8957
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 4 deletions.
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# How to Make a Release
# ---------------------
#
# This file answers the question "how to make a release" hopefully
# better than a document does (only meejah and warner may currently do
# the "upload to PyPI" part anyway)
#

default:
echo "see Makefile"

release-clean:
@echo "Cleanup stale release: " `python newest-version.py`
-rm NEWS.md.asc
-rm dist/magic-wormhole-mailbox-server-`python newest-version.py`.tar.gz*
-rm dist/magic_wormhole_mailbox_server-`python newest-version.py`-py3-none-any.whl*
git tag -d `python newest-version.py`

# create a branch, like: git checkout -b prepare-release-0.16.0
# then run these, so CI can run on the release
release:
@echo "Is checkout clean?"
git diff-files --quiet
git diff-index --quiet --cached HEAD --

@echo "Install required build software"
python -m pip install --editable .[dev,release]

@echo "Test README"
python setup.py check -s

@echo "Is GPG Agent rubnning, and has key?"
gpg --pinentry=loopback -u [email protected] --armor --clear-sign NEWS.md

@echo "Bump version and create tag"
python update-version.py
# python update-version.py --patch # for bugfix release

@echo "Build and sign wheel"
python setup.py bdist_wheel
gpg --pinentry=loopback -u [email protected] --armor --detach-sign dist/magic_wormhole_mailbox_server-`git describe --abbrev=0`-py3-none-any.whl
ls dist/*`git describe --abbrev=0`*

@echo "Build and sign source-dist"
python setup.py sdist
gpg --pinentry=loopback -u [email protected] --armor --detach-sign dist/magic-wormhole-mailbox-server-`git describe --abbrev=0`.tar.gz
ls dist/*`git describe --abbrev=0`*

release-test:
gpg --verify dist/magic-wormhole-mailbox-server-`git describe --abbrev=0`.tar.gz.asc
gpg --verify dist/magic_wormhole_mailbox_server-`git describe --abbrev=0`-py3-none-any.whl.asc
python -m venv testmf_venv
testmf_venv/bin/pip install --upgrade pip
testmf_venv/bin/pip install dist/magic_wormhole_mailbox_server-`git describe --abbrev=0`-py3-none-any.whl
testmf_venv/bin/twistd wormhole-mailbox --version
testmf_venv/bin/pip uninstall -y magic_wormhole_mailbox_server
testmf_venv/bin/pip install dist/magic-wormhole-mailbox-server-`git describe --abbrev=0`.tar.gz
testmf_venv/bin/twistd wormhole-mailbox --version
rm -rf testmf_venv

release-upload:
twine upload --username __token__ --password `cat PRIVATE-release-token` dist/magic_wormhole_mailbox_server-`git describe --abbrev=0`-py3-none-any.whl dist/magic_wormhole_mailbox_server-`git describe --abbrev=0`-py3-none-any.whl.asc dist/magic-wormhole-mailbox-server-`git describe --abbrev=0`.tar.gz dist/magic-wormhole-mailbox-server-`git describe --abbrev=0`.tar.gz.asc
mv dist/*-`git describe --abbrev=0`.tar.gz.asc signatures/
mv dist/*-`git describe --abbrev=0`-py3-none-any.whl.asc signatures/
git add signatures/magic-wormhole-mailbox-server-`git describe --abbrev=0`.tar.gz.asc
git add signatures/magic_wormhole_mailbox_server-`git describe --abbrev=0`-py3-none-any.whl.asc
git commit -m "signatures for release"
git push origin-push `git describe --abbrev=0`


dilation.png: dilation.seqdiag
seqdiag --no-transparency -T png --size 1000x800 -o dilation.png
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ User-visible changes in "magic-wormhole-mailbox-server":

## Upcoming

* (put release-note here when merging / proposing a PR)


## Release 0.5.0 (7-Nov-2024)

* correctly close a mailbox which still has a nameplate (#28)
* remote python2 support
* remove python2 support
* test on python 3.8, 3.9, 3.10, 3.11 and 3.12 series
* drop "six" (#35)
* upgrade "versioneer"
Expand Down
23 changes: 23 additions & 0 deletions newest-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# print out the most-recent version
#

from dulwich.repo import Repo
from dulwich.porcelain import tag_list


def existing_tags(git):
versions = [
tuple(map(int, v.decode("utf8").split(".")))
for v in tag_list(git)
]
return versions


def main():
git = Repo(".")
print("{}.{}.{}".format(*sorted(existing_tags(git))[-1]))


if __name__ == "__main__":
main()
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[wheel]
universal = 1

[versioneer]
VCS = git
versionfile_source = src/wormhole_mailbox_server/_version.py
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
extras_require={
':sys_platform=="win32"': ["pywin32"],
"dev": ["mock", "treq", "tox", "pyflakes"],
"release": ["dulwich", "docutils", "gpg", "wheel"],
},
test_suite="wormhole_mailbox_server.test",
cmdclass=commands,
Expand Down
11 changes: 11 additions & 0 deletions signatures/magic-wormhole-mailbox-server-0.5.0.tar.gz.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----

iQFFBAABCgAvFiEEnVor1WiOy4id680/wmAoAxKAaacFAmcsEawRHG1lZWphaEBt
ZWVqYWguY2EACgkQwmAoAxKAaafF2ggAsgMKP6ZyJ1sqJA58trJaufuV7ypqDJyV
UvPcIMHjF55YIJ2CRXt3fO6QFxiG/WHTWswENKxvFEp2F5ZCe13XLZwugX62/6Hc
T1jCIwvjU93yiEdqPvtMcAX5FWJUMKdOmlCqm/sfP5gF7D34O3vsM6wxbF8YlNFo
No0zZvMDxAlPmNER7iTujnckw5jyHqHSFn5AhWqigJTQlB3Mac7eqXuMIuCCOdy+
8PBpv0+jpdvzuq9hTFNvErKvg/Sy37nC1PJkteIXbneQiJjbVcvK4qniROzDbrnp
zbI+WEtCsm7o3ieLxt5P11fPjO+4/Tf9LwyjmkGnn265fUwrHFMx7g==
=5dEl
-----END PGP SIGNATURE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----

iQFFBAABCgAvFiEEnVor1WiOy4id680/wmAoAxKAaacFAmcsEasRHG1lZWphaEBt
ZWVqYWguY2EACgkQwmAoAxKAaacL7QgAnFo9ilYlzWRlaXBPu/nx86lWzMP8zOKM
LVD94B6wj3vXqosKpe7I3qmGWZrfo0vjHojzzh7GlUMIyapAB4dQ9jJknKOv7cA1
inrCLzObEVJ2JbnZexR7GIwMNhqIWn/PLd1YNygjn9u/sdLTvheGwmZ4vDBIfuTe
w17QRt5Tne2RjBgpNuJBmCz84AQ0TuwW+9ABU3DO6pcFdBQrNYvgmJkUcj8tYfdr
q+FiN5UIEZT0eBPftawY6LA8J7IYJOZk2035KHfxbejA1z2FmogszP1cGhefj/5G
AARkxkoo83Dx18sqlU1h/2vkH8LNwm8U789qm6divYAjrA+hc/J8zw==
=CC6t
-----END PGP SIGNATURE-----
100 changes: 100 additions & 0 deletions update-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#
# this updates the (tagged) version of the software
#
# it will only update the "minor" version (e.g. 0.12.* -> 0.13.0)
#
# Any "options" are hard-coded in here (e.g. the GnuPG key to use)
#

import sys
import time
from datetime import datetime

from dulwich.repo import Repo
from dulwich.porcelain import (
tag_list,
tag_create,
status,
)

from twisted.internet.task import (
react,
)
from twisted.internet.defer import (
ensureDeferred,
)

author = "meejah <[email protected]>"


def existing_tags(git):
versions = [
tuple(map(int, v.decode("utf8").split(".")))
for v in tag_list(git)
]
return versions


def create_new_version(git, only_patch):
versions = existing_tags(git)
major, minor, patch = sorted(versions)[-1]
if only_patch:
next_version = "{}.{}.{}".format(major, minor, patch + 1)
else:
next_version = "{}.{}.{}".format(major, minor + 1, 0)
return next_version


async def main(reactor):
git = Repo(".")

# including untracked files can be very slow (if there are lots,
# like in virtualenvs) and we don't care anyway
st = status(git, untracked_files="no")
if any(st.staged.values()) or st.unstaged:
print("unclean checkout; aborting")
raise SystemExit(1)

for arg in sys.argv[1:]:
if arg not in ("--no-tag", "--patch"):
print("unknown arg: {}".format(arg))
raise SystemExit(2)

v = create_new_version(git, "--patch" in sys.argv)
if "--no-tag" in sys.argv:
print(v)
return

print("Latest version: {}.{}.{}".format(*sorted(existing_tags(git))[-1]))
print("New tag will be {}".format(v))

# the "tag time" is seconds from the epoch .. we quantize these to
# the start of the day in question, in UTC.
now = datetime.now()
s = now.utctimetuple()
ts = int(
time.mktime(
time.struct_time((
s.tm_year, s.tm_mon, s.tm_mday, 0, 0, 0, 0, s.tm_yday, 0
))
)
)
tag_create(
repo=git,
tag=v.encode("utf8"),
author=author.encode("utf8"),
message="release magic-wormhole-{}".format(v).encode("utf8"),
annotated=True,
objectish=b"HEAD",
sign=author.encode("utf8"),
tag_time=ts,
tag_timezone=0,
)

print("Tag created locally, it is not pushed")
print("To push it run something like:")
print(" git push origin {}".format(v))


if __name__ == "__main__":
react(lambda r: ensureDeferred(main(r)))

0 comments on commit fec8957

Please sign in to comment.