Skip to content

Commit ff9c130

Browse files
committed
New: make sure to version the composed app
1 parent 26a7bef commit ff9c130

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

build.py

+29-4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@
5555
)
5656
exit(0)
5757

58+
# read the version from pyproject.toml
59+
with open("pyproject.toml") as f:
60+
pyproject = toml.load(f)
61+
version = pyproject["tool"]["poetry"]["version"]
62+
63+
if "--push" in sys.argv:
64+
try:
65+
with open(".last_version") as f:
66+
last_version = f.read().strip()
67+
except FileNotFoundError:
68+
with open(".last_version", "w") as f:
69+
f.write(version)
70+
last_version = version
71+
72+
if last_version == version:
73+
update_version = input(
74+
f"Do you want to update the version number ({version}) in pyproject.toml?"
75+
)
76+
if update_version.lower() in ["y", "yes"]:
77+
new_version = input("Enter the new version number: ")
78+
subprocess.run(
79+
["poetry", "version", new_version], capture_output=True, check=True
80+
)
81+
console.out("Version updated, don't forget to commit the change.")
82+
version = new_version
83+
5884
res = subprocess.run("docker info", shell=True, capture_output=True)
5985
if res.returncode != 0:
6086
console.print(
@@ -246,6 +272,7 @@ def generate_table(status: dict) -> Table:
246272
for service in ym["services"]:
247273
status[service] = "[grey62]building...[/grey62]"
248274
lt.update(generate_table(status))
275+
# to use a different wheel without editing Dockerfile use --build-arg wheel="wheelname"
249276
command_list = [
250277
"docker",
251278
"compose",
@@ -278,10 +305,6 @@ def generate_table(status: dict) -> Table:
278305
)
279306
exit(1)
280307

281-
# read the version from pyproject.toml
282-
with open("pyproject.toml") as f:
283-
pyproject = toml.load(f)
284-
version = pyproject["tool"]["poetry"]["version"]
285308

286309
# Now if the --push flag was given, push the images to Docker Hub
287310
# For this next part to work you need to be logged in to a docker hub account or the
@@ -313,6 +336,8 @@ def generate_table(status: dict) -> Table:
313336
exit(1)
314337

315338
console.print("Docker images pushed successfully", style="green")
339+
with open(".last_version", "w") as f:
340+
f.write(version)
316341

317342

318343
if "--restart" in sys.argv:

0 commit comments

Comments
 (0)