protonmail-bridge-nextcoud-.../update-check.py

39 lines
938 B
Python
Raw Normal View History

2025-02-17 17:13:35 +00:00
import requests, os, sys
2025-02-17 17:03:25 +00:00
def git(command):
return os.system(f"git {command}")
2025-02-17 17:13:35 +00:00
2025-02-17 17:03:25 +00:00
release = requests.get("https://api.github.com/repos/protonmail/proton-bridge/releases/latest").json()
version = release['tag_name']
deb = [asset for asset in release ['assets'] if asset['name'].endswith('.deb')][0]['browser_download_url']
2025-02-17 17:03:25 +00:00
print(f"Latest release is: {version}")
2025-02-17 17:03:25 +00:00
with open("VERSION", 'w') as f:
f.write(version)
2025-02-17 17:03:25 +00:00
with open("deb/PACKAGE", 'w') as f:
f.write(deb)
2025-02-17 17:03:25 +00:00
git("config --local user.name 'GitHub Actions'")
git("config --local user.email 'actions@github.com'")
2025-02-17 17:03:25 +00:00
git("add -A")
2025-02-17 17:03:25 +00:00
if git("diff --cached --quiet") == 0: # Returns 0 if there are no changes
print("Version didn't change")
exit(1)
2025-02-17 17:03:25 +00:00
git(f"commit -m 'Bump version to {version}'")
2025-02-17 17:13:35 +00:00
is_pull_request = sys.argv[1] == "true"
if is_pull_request:
print("This is a pull request, skipping push step.")
exit(0)
2025-02-17 17:03:25 +00:00
if git("push") != 0:
print("Git push failed!")
exit(1)