-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
38 lines (26 loc) · 773 Bytes
/
build.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
import json
import os
import datetime
with open("package.json", "r") as f:
data = json.load(f)
prevVersion = data["version"]
prevYear = int(prevVersion[0:2])
prevWeek = int(prevVersion[3:5])
prevCount = prevVersion[-1]
year, week, weekday = datetime.date.today().isocalendar()
year %= 100
if year == prevYear and week == prevWeek:
count = chr(ord(prevCount) + 1)
else:
count = "a"
version = f"{year}w{str(week).zfill(2)}{count}"
data["version"] = version
print(f"Version modified: {prevVersion} -> {version}")
with open("package.json", "w") as f:
f.write(json.dumps(data, indent=2))
with open("index.html", "r") as f:
html = f.read()
html = html.replace(prevVersion, version)
with open("index.html", "w") as f:
f.write(html)
os.system("npm run package")