-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.py
More file actions
34 lines (27 loc) · 1.07 KB
/
release.py
File metadata and controls
34 lines (27 loc) · 1.07 KB
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
import os
import zipfile
base_dir = "."
include_dirs = ["fonts", "icons", "scripts", "settings", "styles"]
include_files = ["index.html", "manifest.json"]
zip_name = "New Tab Extension.zip"
if os.path.exists(zip_name):
try:
os.remove(zip_name)
print(f"🗑️ Old archive {zip_name} was deleted.")
except Exception as e:
print(f"⚠️ Can't delete old archive {zip_name}: {e}")
exit(1)
with zipfile.ZipFile(zip_name, "w", zipfile.ZIP_DEFLATED) as zipf:
for folder in include_dirs:
folder_path = os.path.join(base_dir, folder)
if os.path.exists(folder_path):
for root, _, files in os.walk(folder_path):
for file in files:
abs_path = os.path.join(root, file)
rel_path = os.path.relpath(abs_path, base_dir)
zipf.write(abs_path, rel_path)
for file in include_files:
file_path = os.path.join(base_dir, file)
if os.path.exists(file_path):
zipf.write(file_path, file)
print(f"✅ Release archive {zip_name} done.")