Release LanUps 0.1.2 with native installers and monitoring updates

This commit is contained in:
tongtong committed 2026-11-28 21:18:14 +08:00
1 parent 90c57f020f
commit 5bdc79d8e4
30 files changed
+751 -270

No files matched your search

+16 -20
View File
@@ -8,12 +8,12 @@ import plistlib
import struct
import sys
import tarfile
import zipfile
DEPLOY = Path(__file__).resolve().parent
ROOT = DEPLOY.parent.parent
VERSION = (ROOT / 'VERSION').read_text(encoding='ascii').strip()
PAYLOAD = Path(os.environ.get('LANUPS_INSTALLER_PAYLOAD', ROOT / 'artifacts' / 'installer-payload-optimized')).resolve()
DIST = ROOT / 'artifacts' / 'installers'
DIST = ROOT / 'dist'
ICON = DEPLOY.parent / 'src' / 'LanUps.Desktop' / 'Assets' / 'ups.png'
@@ -42,6 +42,8 @@ def unix_package(rid):
tar_bytes(archive, 'architecture', rid.split('-', 1)[1].encode() + b'\n', 0o644)
folder = DEPLOY / ('macos' if mac else 'linux')
for sidecar in sorted(folder.iterdir()):
if sidecar.suffix == '.spec':
continue
tar_bytes(archive, sidecar.name, sidecar.read_bytes(), 0o644)
for kind in ('Agent', 'Desktop'):
prefix = 'LanUps.app/Contents/MacOS' if mac and kind == 'Desktop' else kind.lower()
@@ -54,7 +56,7 @@ def unix_package(rid):
if mac:
info = dict(CFBundleExecutable='LanUps.Desktop', CFBundleIdentifier='local.lanups.desktop',
CFBundleName='LanUps', CFBundleDisplayName='局域网 UPS', CFBundlePackageType='APPL',
CFBundleIconFile='ups.icns', CFBundleVersion='1', CFBundleShortVersionString='0.1.0')
CFBundleIconFile='ups.icns', CFBundleVersion=VERSION, CFBundleShortVersionString=VERSION)
tar_bytes(archive, 'LanUps.app/Contents/Info.plist', plistlib.dumps(info), 0o644)
png = ICON.read_bytes()
image = b'icns' + struct.pack('>I', len(png) + 16) + b'ic08' + struct.pack('>I', len(png) + 8) + png
@@ -64,20 +66,18 @@ def unix_package(rid):
return path
def windows_package(rid, path=None):
path = path or DIST / f'LanUps-{rid}.zip'
path.parent.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED, compresslevel=5) as archive:
for filename in ('Setup.cmd', 'Setup.ps1', 'install.ps1'):
script = (DEPLOY / 'windows' / filename).read_text(encoding='utf-8-sig')
archive.writestr(filename, script.replace('\n', '\r\n').encode('utf-8-sig' if filename.endswith('.ps1') else 'ascii'))
for kind in ('Agent', 'Desktop'):
for source, filename, _ in binaries(rid, kind):
archive.write(source, f'{kind}/{filename}')
return path
def write_checksums():
extensions = ('.exe', '.deb', '.rpm', '.pkg', '.ipk', '.tar.gz')
with (DIST / 'SHA256SUMS').open('w', encoding='ascii', newline='\n') as sums:
for path in sorted(DIST.iterdir()):
if path.is_file() and path.name.endswith(extensions):
with path.open('rb') as stream:
sums.write(f"{hashlib.file_digest(stream, 'sha256').hexdigest()} {path.name}\n")
def main(targets):
if any(rid.startswith('win-') for rid in targets):
raise ValueError('Use package.ps1 to build the Windows Inno Setup installer.')
DIST.mkdir(parents=True, exist_ok=True)
router = DIST / 'LanUps-openwrt.tar.gz'
with tarfile.open(router, 'w:gz') as archive:
@@ -85,13 +85,9 @@ def main(targets):
tar_bytes(archive, source.name, source.read_bytes().replace(b'\r\n', b'\n'), 0o755)
print(router.name, flush=True)
for rid in targets:
path = windows_package(rid) if rid.startswith('win-') else unix_package(rid)
path = unix_package(rid)
print(path.name, flush=True)
archives = sorted([*DIST.glob('LanUps-*.zip'), *DIST.glob('LanUps-*.tar.gz')])
with (DIST / 'SHA256SUMS').open('w', encoding='ascii', newline='\n') as sums:
for path in archives:
with path.open('rb') as stream:
sums.write(f"{hashlib.file_digest(stream, 'sha256').hexdigest()} {path.name}\n")
write_checksums()
if __name__ == '__main__':