feat: adding ota updates

This commit is contained in:
Chubby Granny Chaser
2025-10-13 23:53:44 +01:00
parent cd136c07a6
commit 0ae3e35cb4
5 changed files with 43 additions and 62 deletions

View File

@@ -4,7 +4,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
on: push on:
push:
branches: main
jobs: jobs:
build: build:
@@ -28,11 +30,11 @@ jobs:
RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.EXTERNAL_RESOURCES_URL }} RENDERER_VITE_EXTERNAL_RESOURCES_URL: ${{ vars.EXTERNAL_RESOURCES_URL }}
- name: Deploy to Cloudflare Pages - name: Deploy to Cloudflare Pages
run: |
npx --yes wrangler@3 pages deploy out/renderer \
--project-name=hydra-staging \
--commit-dirty=true \
--branch=main
env: env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
npx --yes wrangler@3 pages deploy out/renderer \
--project-name="hydra" \
--commit-dirty=true \
--branch="main"

View File

@@ -57,6 +57,7 @@ jobs:
RENDERER_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }} RENDERER_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
RENDERER_VITE_REAL_DEBRID_REFERRAL_ID: ${{ vars.RENDERER_VITE_REAL_DEBRID_REFERRAL_ID }} RENDERER_VITE_REAL_DEBRID_REFERRAL_ID: ${{ vars.RENDERER_VITE_REAL_DEBRID_REFERRAL_ID }}
RENDERER_VITE_TORBOX_REFERRAL_CODE: ${{ vars.RENDERER_VITE_TORBOX_REFERRAL_CODE }} RENDERER_VITE_TORBOX_REFERRAL_CODE: ${{ vars.RENDERER_VITE_TORBOX_REFERRAL_CODE }}
MAIN_VITE_RENDERER_URL: ${{ vars.MAIN_VITE_RENDERER_URL }}
- name: Build Windows - name: Build Windows
if: matrix.os == 'windows-2022' if: matrix.os == 'windows-2022'
@@ -73,6 +74,7 @@ jobs:
RENDERER_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }} RENDERER_VITE_SENTRY_DSN: ${{ vars.SENTRY_DSN }}
RENDERER_VITE_REAL_DEBRID_REFERRAL_ID: ${{ vars.RENDERER_VITE_REAL_DEBRID_REFERRAL_ID }} RENDERER_VITE_REAL_DEBRID_REFERRAL_ID: ${{ vars.RENDERER_VITE_REAL_DEBRID_REFERRAL_ID }}
RENDERER_VITE_TORBOX_REFERRAL_CODE: ${{ vars.RENDERER_VITE_TORBOX_REFERRAL_CODE }} RENDERER_VITE_TORBOX_REFERRAL_CODE: ${{ vars.RENDERER_VITE_TORBOX_REFERRAL_CODE }}
MAIN_VITE_RENDERER_URL: ${{ vars.MAIN_VITE_RENDERER_URL }}
- name: Create artifact - name: Create artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@@ -1,23 +0,0 @@
FROM node:22-alpine AS builder
# Install git (required for git dependencies)
RUN apk add --no-cache git
WORKDIR /app
COPY package.json yarn.lock ./
# Install dependencies but skip postinstall scripts (electron-builder deps not needed for web build)
RUN yarn install --frozen-lockfile --ignore-scripts
COPY . .
RUN yarn electron-vite build
FROM nginx:alpine
COPY --from=builder /app/out/renderer /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -54,20 +54,37 @@ export class WindowManager {
show: false, show: false,
}; };
private static loadMainWindowURL(hash = "") { private static async loadWindowURL(window: BrowserWindow, hash: string = "") {
// HMR for renderer base on electron-vite cli. // HMR for renderer base on electron-vite cli.
// Load the remote URL for development or the local html file for production. // Load the remote URL for development or the local html file for production.
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) { if (is.dev && process.env["ELECTRON_RENDERER_URL"]) {
this.mainWindow?.loadURL( window.loadURL(`${process.env["ELECTRON_RENDERER_URL"]}#/${hash}`);
`${process.env["ELECTRON_RENDERER_URL"]}#/${hash}` } else if (process.env["MAIN_VITE_RENDERER_URL"]) {
); // Try to load from remote URL in production
} else { try {
this.mainWindow?.loadFile( await window.loadURL(
path.join(__dirname, "../renderer/index.html"), `${import.meta.env.MAIN_VITE_RENDERER_URL}#/${hash}`
{ );
} catch (error) {
// Fall back to local file if remote URL fails
console.error(
"Failed to load from MAIN_VITE_RENDERER_URL, falling back to local file:",
error
);
window.loadFile(path.join(__dirname, "../renderer/index.html"), {
hash, hash,
} });
); }
} else {
window.loadFile(path.join(__dirname, "../renderer/index.html"), {
hash,
});
}
}
private static async loadMainWindowURL(hash: string = "") {
if (this.mainWindow) {
await this.loadWindowURL(this.mainWindow, hash);
} }
} }
@@ -268,17 +285,8 @@ export class WindowManager {
} }
private static loadNotificationWindowURL() { private static loadNotificationWindowURL() {
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) { if (this.notificationWindow) {
this.notificationWindow?.loadURL( this.loadWindowURL(this.notificationWindow, "achievement-notification");
`${process.env["ELECTRON_RENDERER_URL"]}#/achievement-notification`
);
} else {
this.notificationWindow?.loadFile(
path.join(__dirname, "../renderer/index.html"),
{
hash: "achievement-notification",
}
);
} }
} }
@@ -450,19 +458,10 @@ export class WindowManager {
editorWindow.removeMenu(); editorWindow.removeMenu();
if (is.dev && process.env["ELECTRON_RENDERER_URL"]) { this.loadWindowURL(editorWindow, `theme-editor?themeId=${themeId}`);
editorWindow.loadURL(
`${process.env["ELECTRON_RENDERER_URL"]}#/theme-editor?themeId=${themeId}`
);
} else {
editorWindow.loadFile(path.join(__dirname, "../renderer/index.html"), {
hash: `theme-editor?themeId=${themeId}`,
});
}
editorWindow.once("ready-to-show", () => { editorWindow.once("ready-to-show", () => {
editorWindow.show(); editorWindow.show();
this.mainWindow?.webContents.openDevTools();
if (!app.isPackaged || isStaging) { if (!app.isPackaged || isStaging) {
editorWindow.webContents.openDevTools(); editorWindow.webContents.openDevTools();
} }
@@ -470,12 +469,11 @@ export class WindowManager {
editorWindow.webContents.on("before-input-event", (_event, input) => { editorWindow.webContents.on("before-input-event", (_event, input) => {
if (input.key === "F12") { if (input.key === "F12") {
this.mainWindow?.webContents.toggleDevTools(); editorWindow.webContents.toggleDevTools();
} }
}); });
editorWindow.on("close", () => { editorWindow.on("close", () => {
this.mainWindow?.webContents.closeDevTools();
this.editorWindows.delete(themeId); this.editorWindows.delete(themeId);
}); });
} }

View File

@@ -7,6 +7,8 @@ interface ImportMetaEnv {
readonly MAIN_VITE_CHECKOUT_URL: string; readonly MAIN_VITE_CHECKOUT_URL: string;
readonly MAIN_VITE_EXTERNAL_RESOURCES_URL: string; readonly MAIN_VITE_EXTERNAL_RESOURCES_URL: string;
readonly MAIN_VITE_WS_URL: string; readonly MAIN_VITE_WS_URL: string;
readonly MAIN_VITE_RENDERER_URL: string;
readonly ELECTRON_RENDERER_URL: string;
} }
interface ImportMeta { interface ImportMeta {