5 from datetime
import datetime
, timezone
8 script_dir
= os
.path
.dirname(os
.path
.realpath(__file__
))
9 project_root
= os
.path
.dirname(script_dir
)
10 platform
= sys
.argv
[1]
13 def sha512sum(filename
):
15 with
open(filename
, "rb") as f
:
16 for chunk
in iter(lambda: f
.read(4096), b
""):
20 def to_release_file(file):
22 dl_base
= f
"https://proton.me/download/pass/{platform}"
23 sha
= sha512sum(os
.path
.join(file['Dir'], name
))
26 'Url': f
"{dl_base}/{file['Name']}",
27 'Sha512CheckSum': sha
,
31 if 'Identifier' in file:
32 release_file
['Identifier'] = file['Identifier']
38 print("PASS_RELEASE_CHANNEL not set")
41 with
open(os
.path
.join(project_root
, "package.json")) as f
:
42 version
= json
.load(f
)["version"]
46 if platform
== "windows":
48 'Name': f
"ProtonPass_Setup_{version}.exe",
49 'Dir': os
.path
.join(project_root
, 'out', 'make', 'squirrel.windows', 'x64'),
51 elif platform
== "macos":
53 'Name': f
"ProtonPass_{version}.dmg",
54 'Dir': os
.path
.join(project_root
, 'out', 'make'),
56 elif platform
== "linux":
58 'Name': f
"proton-pass_{version}_amd64.deb",
59 'Identifier': '.deb (Ubuntu/Debian)',
60 'Dir': os
.path
.join(project_root
, 'out', 'make', 'deb', 'x64'),
63 'Name': f
"proton-pass-{version}-1.x86_64.rpm",
64 'Identifier': '.rpm (Fedora/RHEL)',
65 'Dir': os
.path
.join(project_root
, 'out', 'make', 'rpm', 'x64'),
68 now
= datetime
.now(timezone
.utc
).strftime("%Y-%m-%dT%H:%M:%SZ")
69 version_json_path
= f
"assets/{platform}/version.json"
70 if not os
.path
.isfile(version_json_path
):
71 with
open(version_json_path
, "w") as f
:
72 json
.dump({"Releases": []}, f
)
74 with
open(version_json_path
) as f
:
75 version_json
= json
.load(f
)
78 "CategoryName": channel
,
81 "RolloutPercentage": 0.2,
82 "File": list(map(to_release_file
, files
))
85 version_json
["Releases"].insert(0, new_release
)
86 with
open(version_json_path
, "w") as f
:
87 print(f
"*** Prepending {new_release}")
88 json
.dump(version_json
, f
, indent
=2)
91 if __name__
== "__main__":