| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
""" |
| 18 |
Release code |
| 19 |
~~~~~~~~~~~~ |
| 20 |
|
| 21 |
""" |
| 22 |
|
| 23 |
import re as _re |
| 24 |
|
| 25 |
|
| 26 |
def check_committed(ctx): |
| 27 |
"""Check if everything is committed""" |
| 28 |
git = ctx.shell.frompath("git") |
| 29 |
lines = ctx.run( |
| 30 |
ctx.c("%s branch --color=never", git), env=dict(LC_ALL="C"), hide=True |
| 31 |
).stdout.splitlines() |
| 32 |
for line in lines: |
| 33 |
if line.startswith("*"): |
| 34 |
branch = line.split(None, 1)[1] |
| 35 |
break |
| 36 |
else: |
| 37 |
ctx.fail("Could not determine current branch.") |
| 38 |
|
| 39 |
if branch != "master": |
| 40 |
rex = _re.compile(r"^\d+(?:\.\d+)*\.[xX]$").match |
| 41 |
match = rex(branch) |
| 42 |
if not match: |
| 43 |
ctx.fail("Not in master or release branch.") |
| 44 |
|
| 45 |
lines = ctx.run( |
| 46 |
ctx.c("%s status --porcelain", git), env=dict(LC_ALL="C"), hide=True |
| 47 |
).stdout |
| 48 |
if lines: |
| 49 |
ctx.fail("Uncommitted changes!") |
| 50 |
|
| 51 |
|
| 52 |
def add_tag(ctx): |
| 53 |
"""Add release tag""" |
| 54 |
version = ctx.run("python setup.py --version", hide=True).stdout.strip() |
| 55 |
git = ctx.shell.frompath("git") |
| 56 |
|
| 57 |
ctx.run( |
| 58 |
ctx.c( |
| 59 |
""" |
| 60 |
%s tag -a -m "Release version %s" -- %s |
| 61 |
""", |
| 62 |
git, |
| 63 |
version, |
| 64 |
version, |
| 65 |
), |
| 66 |
echo=True, |
| 67 |
) |