Skip to content

Commit

Permalink
Block release if git unclean (#366)
Browse files Browse the repository at this point in the history
* Stop release process if repo is not clean
* Update test_release_date
  Now can match versions with alphanumeric suffixes
* Give last chance to cancel upload after build
* Bump version to 1.4.4.post2
  • Loading branch information
pepoluan committed Jan 19, 2023
1 parent 4bd08bb commit 83168cd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aiosmtpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import warnings


__version__ = "1.4.4"
__version__ = "1.4.4.post2"


def _get_or_new_eventloop() -> asyncio.AbstractEventLoop:
Expand Down
9 changes: 9 additions & 0 deletions aiosmtpd/docs/NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Fixed/Improved
* A whole bunch of annotations


1.4.4.post2 (2023-01-19)
========================

Fixed/Improved
--------------
* Prevent unclean repo from being built (Closes #365)
* Reduce chance of not-ready-for-release packages from being uploaded


1.4.4 (2023-01-17)
==================

Expand Down
2 changes: 1 addition & 1 deletion aiosmtpd/qa/test_0packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from aiosmtpd import __version__

RE_DUNDERVER = re.compile(r"__version__\s*?=\s*?(['\"])(?P<ver>[^'\"]+)\1\s*$")
RE_VERHEADING = re.compile(r"(?P<ver>[0-9.]+)\s*\((?P<date>[^)]+)\)")
RE_VERHEADING = re.compile(r"(?P<ver>([0-9.]+)\S*)\s*\((?P<date>[^)]+)\)")


@pytest.fixture
Expand Down
15 changes: 15 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
printfl = partial(print, flush=True)
run_hidden = partial(subprocess.run, stdout=subprocess.PIPE)

result = run_hidden(shlex.split("git status --porcelain"))
if result.stdout:
print("git is not clean!")
print("Please commit/shelf first before releasing!")
sys.exit(1)

TWINE_CONFIG = Path(os.environ.get("TWINE_CONFIG", "~/.pypirc")).expanduser()
TWINE_REPO = os.environ.get("TWINE_REPOSITORY", "aiosmtpd")
UPSTREAM_REMOTE = os.environ.get("UPSTREAM_REMOTE", "upstream")
Expand Down Expand Up @@ -101,7 +107,16 @@
# Assuming twine is installed.
print("### twine check")
subprocess.run(["twine", "check"] + DISTFILES, check=True)
except subprocess.CalledProcessError as e:
print("ERROR: Last step returned exitcode != 0")
sys.exit(e.returncode)

choice = input("Ready to upload to PyPI? [y/N]: ")
if choice.casefold() not in ("y", "yes"):
print("Okay.")
sys.exit(0)

try:
# You should have an aiosmtpd bit setup in your ~/.pypirc - for twine
twine_up = f"twine upload --config-file {TWINE_CONFIG} -r {TWINE_REPO}".split()
if GPG_SIGNING_ID:
Expand Down

0 comments on commit 83168cd

Please sign in to comment.