mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 06:51:47 -03:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user