-
Notifications
You must be signed in to change notification settings - Fork 96
/
noxfile.py
63 lines (49 loc) · 1.46 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import subprocess
import sys
from pathlib import Path
import nox # type: ignore
nox.options.reuse_existing_virtualenvs = True
@nox.session()
def run(session):
session.install(".")
session.run("python", "-m", "pyxtermjs", *session.posargs)
def has_changes():
status = (
subprocess.run(
"git status --porcelain", shell=True, check=True, stdout=subprocess.PIPE
)
.stdout.decode()
.strip()
)
return len(status) > 0
def on_master_no_changes(session):
if has_changes():
session.error("All changes must be committed or removed before publishing")
# branch = get_branch()
# if branch != "master":
# session.error(f"Must be on 'master' branch. Currently on {branch!r} branch")
def get_branch():
return (
subprocess.run(
"git rev-parse --abbrev-ref HEAD",
shell=True,
check=True,
stdout=subprocess.PIPE,
)
.stdout.decode()
.strip()
)
@nox.session()
def build(session):
session.install("--upgrade", "pip")
session.install("build")
session.run("rm", "-rf", "dist", "build", external=True)
session.run("python", "-m", "build")
@nox.session()
def publish(session):
on_master_no_changes(session)
session.install("--upgrade", "pip")
session.install("twine")
build(session)
print("REMINDER: Has the changelog been updated?")
session.run("python", "-m", "twine", "upload", "dist/*")