From 0a71fdac8cdd811a305afef8ed411dadb0d44c23 Mon Sep 17 00:00:00 2001 From: sanasol Date: Fri, 20 Feb 2026 11:55:35 +0100 Subject: [PATCH] v2.3.0: migrate auto-update to Forgejo, add Arch build - Switch auto-update from GitHub to Forgejo (generic provider) - Dynamically resolve latest release URL via Forgejo API - Add pacman target to Linux builds - Hide direct upload URL in repository secret Co-Authored-By: Claude Opus 4.6 --- backend/appUpdater.js | 44 +++++++++++++++++++++++++++++++++++++++---- dev-app-update.yml | 5 ++--- package.json | 7 +++---- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/backend/appUpdater.js b/backend/appUpdater.js index 9a93636..a48ef5c 100644 --- a/backend/appUpdater.js +++ b/backend/appUpdater.js @@ -4,6 +4,10 @@ const logger = require('./logger'); const fs = require('fs'); const path = require('path'); const os = require('os'); +const https = require('https'); + +const FORGEJO_API = 'https://git.sanhost.net/api/v1'; +const FORGEJO_REPO = 'sanasol/hytale-f2p'; class AppUpdater { constructor(mainWindow) { @@ -14,6 +18,34 @@ class AppUpdater { this.setupAutoUpdater(); } + /** + * Fetch the latest non-draft release tag from Forgejo and set the feed URL + */ + async _resolveUpdateUrl() { + return new Promise((resolve, reject) => { + https.get(`${FORGEJO_API}/repos/${FORGEJO_REPO}/releases?limit=5`, (res) => { + let data = ''; + res.on('data', (chunk) => data += chunk); + res.on('end', () => { + try { + const releases = JSON.parse(data); + const latest = releases.find(r => !r.draft && !r.prerelease); + if (latest) { + const url = `https://git.sanhost.net/${FORGEJO_REPO}/releases/download/${latest.tag_name}`; + console.log(`Auto-update URL resolved to: ${url}`); + autoUpdater.setFeedURL({ provider: 'generic', url }); + resolve(url); + } else { + reject(new Error('No published release found')); + } + } catch (e) { + reject(e); + } + }); + }).on('error', reject); + }); + } + setupAutoUpdater() { // Configure logger for electron-updater @@ -216,8 +248,10 @@ class AppUpdater { } checkForUpdatesAndNotify() { - // Check for updates and notify if available - autoUpdater.checkForUpdatesAndNotify().catch(err => { + // Resolve latest release URL then check for updates + this._resolveUpdateUrl().catch(err => { + console.warn('Failed to resolve update URL:', err.message); + }).then(() => autoUpdater.checkForUpdatesAndNotify()).catch(err => { console.error('Failed to check for updates:', err); // Network errors are not critical - just log and continue @@ -245,8 +279,10 @@ class AppUpdater { } checkForUpdates() { - // Manual check for updates (returns promise) - return autoUpdater.checkForUpdates().catch(err => { + // Manual check - resolve latest release URL first + return this._resolveUpdateUrl().catch(err => { + console.warn('Failed to resolve update URL:', err.message); + }).then(() => autoUpdater.checkForUpdates()).catch(err => { console.error('Failed to check for updates:', err); // Network errors are not critical - just return no update available diff --git a/dev-app-update.yml b/dev-app-update.yml index f2dfe15..d2efd77 100644 --- a/dev-app-update.yml +++ b/dev-app-update.yml @@ -1,3 +1,2 @@ -provider: github -owner: amiayweb # Change to your own GitHub username -repo: Hytale-F2P +provider: generic +url: https://git.sanhost.net/sanasol/hytale-f2p/releases/latest/download diff --git a/package.json b/package.json index 0ad2b68..42f54bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hytale-f2p-launcher", - "version": "2.2.2", + "version": "2.3.0", "description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support", "homepage": "https://github.com/amiayweb/Hytale-F2P", "main": "main.js", @@ -118,9 +118,8 @@ "createStartMenuShortcut": true }, "publish": { - "provider": "github", - "owner": "amiayweb", - "repo": "Hytale-F2P" + "provider": "generic", + "url": "https://git.sanhost.net/sanasol/hytale-f2p/releases/latest/download" } } }