extension-builder/main.py

47 lines
1 KiB
Python
Raw Normal View History

from requests import get
import subprocess, os
oldVer = ""
try:
from localVersionCache import oldVer # pyright: ignore [reportMissingImports]
except:
...
2025-01-21 20:02:53 +00:00
current = get(
"https://api.github.com/repos/material-extensions/material-icons-browser-extension/releases/latest"
).json()
version = current["name"]
if version == oldVer:
exit(0)
2025-01-21 20:02:53 +00:00
subprocess.run(
[
"rm",
"-rf",
"github-material-icons-chrome-extension",
"github-material-icons-chrome-extension.zip",
]
)
# Below is modifed from https://stackoverflow.com/a/16696317
file = get(current["assets"][0]["browser_download_url"], stream=True)
with open("github-material-icons-chrome-extension.zip", "wb") as f:
for chunk in file.iter_content(chunk_size=8192):
f.write(chunk)
2025-01-21 20:02:53 +00:00
os.mkdir("github-material-icons-chrome-extension")
2025-01-21 20:02:53 +00:00
subprocess.run(
[
"unzip",
"github-material-icons-chrome-extension.zip",
"-d",
"github-material-icons-chrome-extension",
]
)