refactor(windows): publish Velopack updates through Gitea Releases
This commit is contained in:
1 parent
826745b407
commit
1ef8edc8bc
17 files changed
+519
-87
No files matched your search
@@ -12,6 +12,7 @@ from urllib.parse import urljoin, urlparse
|
||||
from urllib.request import url2pathname
|
||||
|
||||
from check_windows_release import audit
|
||||
from update_versions import numeric_version, update_version
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
def resolved_deskup():
|
||||
@@ -58,12 +59,6 @@ def pack_release(command, *, app, output, package_id, version, title):
|
||||
'--delta', 'none'], check=True)
|
||||
|
||||
|
||||
def update_version(display_version, build):
|
||||
version = display_version + '-build.' + str(int(build))
|
||||
numeric_version(version)
|
||||
return version
|
||||
|
||||
|
||||
def file_version(app):
|
||||
import pefile
|
||||
with pefile.PE(str(app / 'cutdex.exe')) as pe:
|
||||
@@ -78,17 +73,6 @@ def file_version(app):
|
||||
raise ValueError('Missing Flutter display version and build number in PE resources')
|
||||
|
||||
|
||||
def numeric_version(version):
|
||||
number = r'(0|[1-9]\d*)'
|
||||
match = re.fullmatch(rf'{number}\.{number}\.{number}(?:-build\.{number})?', version)
|
||||
if not match:
|
||||
raise ValueError('Windows update versions must use major.minor.patch-build.number')
|
||||
major, minor, patch, build = match.groups()
|
||||
# SemVer build metadata (+number) does not participate in precedence.
|
||||
# A numeric prerelease component does, and stable versions rank above it.
|
||||
return (int(major), int(minor), int(patch), int(build is None), int(build or 0))
|
||||
|
||||
|
||||
def validate_previous(output, package_id, version):
|
||||
candidate = numeric_version(version)
|
||||
for feed in output.glob('releases.*.json'):
|
||||
@@ -120,28 +104,28 @@ def verify_manifest(app):
|
||||
raise ValueError(f'Release checksum mismatch: {name}')
|
||||
|
||||
|
||||
def package(args):
|
||||
app, output = args.app.resolve(), args.output.resolve()
|
||||
def package_app(app, output, vpk, *, development=False, require_processing=True):
|
||||
app, output = Path(app).resolve(), Path(output).resolve()
|
||||
if output == app or output.is_relative_to(app) or app.is_relative_to(output):
|
||||
raise ValueError('Release output must be outside the staged app')
|
||||
audit(app)
|
||||
audit(app, require_processing=require_processing)
|
||||
verify_manifest(app)
|
||||
sdk_dll = app / 'velopack_libc.dll'
|
||||
if not sdk_dll.is_file():
|
||||
raise ValueError('Rebuild the app with the Velopack integration before packaging')
|
||||
command = vpk_command(args.vpk)
|
||||
command = vpk_command(vpk)
|
||||
check_tool(command)
|
||||
version = file_version(app)
|
||||
package_id = 'Cutdex.Dev' if args.development else 'Cutdex'
|
||||
# The expected identity is compiled into the runner and must match the package.
|
||||
package_id = 'Cutdex.Dev' if development else 'Cutdex'
|
||||
# deskup compiles the identity into the plugin, rather than the runner.
|
||||
identity = package_id.encode('ascii') + b'\0'
|
||||
if identity not in (app / 'cutdex.exe').read_bytes():
|
||||
if identity not in (app / 'deskup_plugin.dll').read_bytes():
|
||||
raise ValueError('Package identity does not match the Flutter build flavor')
|
||||
validate_previous(output, package_id, version)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
pack_release(command, app=app, output=output, package_id=package_id, version=version,
|
||||
title='Cutdex Dev' if args.development else 'Cutdex')
|
||||
print(json.dumps({'version': version, 'packageId': package_id, 'output': str(output)}))
|
||||
title='Cutdex Dev' if development else 'Cutdex')
|
||||
return {'version': version, 'packageId': package_id, 'output': str(output)}
|
||||
|
||||
|
||||
def serve(directory, port):
|
||||
@@ -168,7 +152,8 @@ def main():
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
if args.command == 'pack':
|
||||
package(args)
|
||||
print(json.dumps(package_app(args.app, args.output, args.vpk,
|
||||
development=args.development)))
|
||||
else:
|
||||
serve(args.directory, args.port)
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in new issue
Block a user