forked from RSSNext/Follow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infra): electron app can hot update renderer layer (RSSNext#1209)
* ci Signed-off-by: Innei <i@innei.in> * feat: hotupdate renderer impl * fix: skip dev Signed-off-by: Innei <i@innei.in> * update logci Signed-off-by: Innei <i@innei.in> * update logci Signed-off-by: Innei <i@innei.in> * feat: tracker Signed-off-by: Innei <tukon479@gmail.com> * log Signed-off-by: Innei <tukon479@gmail.com> * fix: hash Signed-off-by: Innei <tukon479@gmail.com> * fix: build Signed-off-by: Innei <tukon479@gmail.com> * fix: deps Signed-off-by: Innei <tukon479@gmail.com> * Update nightly.yml * update Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * update minimunm Signed-off-by: Innei <tukon479@gmail.com> * calc main hash Signed-off-by: Innei <tukon479@gmail.com> * add main Hash logic Signed-off-by: Innei <tukon479@gmail.com> * remove Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> * log Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * test Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix: update Signed-off-by: Innei <tukon479@gmail.com> * debug Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix: only one Signed-off-by: Innei <tukon479@gmail.com> * try fix cookie Signed-off-by: Innei <tukon479@gmail.com> * update Signed-off-by: Innei <tukon479@gmail.com> * fix cookie Signed-off-by: Innei <tukon479@gmail.com> * fix: domain Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> * fix: remove test code Signed-off-by: Innei <tukon479@gmail.com> * fix Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <i@innei.in> Signed-off-by: Innei <tukon479@gmail.com>
- Loading branch information
Showing
37 changed files
with
1,025 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Build Electron Render | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
env: | ||
VITE_WEB_URL: ${{ vars.VITE_WEB_URL }} | ||
VITE_API_URL: ${{ vars.VITE_API_URL }} | ||
VITE_IMGPROXY_URL: ${{ vars.VITE_IMGPROXY_URL }} | ||
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }} | ||
VITE_OPENPANEL_CLIENT_ID: ${{ vars.VITE_OPENPANEL_CLIENT_ID }} | ||
VITE_OPENPANEL_API_URL: ${{ vars.VITE_OPENPANEL_API_URL }} | ||
VITE_FIREBASE_CONFIG: ${{ vars.VITE_FIREBASE_CONFIG }} | ||
NODE_OPTIONS: --max-old-space-size=8192 | ||
|
||
jobs: | ||
build-render: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
attestations: write | ||
|
||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.pnpm-store | ||
key: ${{ matrix.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ matrix.os }}- | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm i | ||
- name: Build | ||
run: pnpm build:render | ||
env: | ||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
|
||
- name: Setup Version | ||
id: version | ||
uses: ./.github/actions/setup-version | ||
|
||
- name: Create Release Draft | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
name: v${{ steps.version.outputs.APP_VERSION }} | ||
draft: false | ||
prerelease: true | ||
tag_name: v${{ steps.version.outputs.APP_VERSION }} | ||
files: | | ||
dist/manifest.yml | ||
dist/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
import "../../types/vite" | ||
import "../../types/authjs" | ||
|
||
declare global { | ||
const GIT_COMMIT_HASH: string | ||
} | ||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
// 5min | ||
import path from "node:path" | ||
|
||
import { app } from "electron" | ||
|
||
export const UNREAD_BACKGROUND_POLLING_INTERVAL = 1000 * 60 * 5 | ||
|
||
export const HOTUPDATE_RENDER_ENTRY_DIR = path.resolve(app.getPath("userData"), "render") | ||
|
||
export const GITHUB_OWNER = process.env.GITHUB_OWNER || "RSSNext" | ||
export const GITHUB_REPO = process.env.GITHUB_REPO || "follow" | ||
|
||
// https://github.com/electron/electron/issues/25081 | ||
export const START_IN_TRAY_ARGS = "--start-in-tray" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { machineIdSync } from "node-machine-id" | ||
|
||
export const DEVICE_ID = machineIdSync() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { env } from "@follow/shared/env" | ||
import { OpenPanel } from "@openpanel/web" | ||
import { app } from "electron" | ||
|
||
import { DEVICE_ID } from "~/constants/system" | ||
|
||
export const op = new OpenPanel({ | ||
clientId: env.VITE_OPENPANEL_CLIENT_ID ?? "", | ||
trackScreenViews: false, | ||
trackOutgoingLinks: false, | ||
trackAttributes: false, | ||
trackHashChanges: false, | ||
apiUrl: env.VITE_OPENPANEL_API_URL, | ||
}) | ||
|
||
op.setGlobalProperties({ | ||
device_id: DEVICE_ID, | ||
app_version: app.getVersion(), | ||
build: "electron", | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
import type { BrowserWindow } from "electron" | ||
|
||
export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) | ||
// To solve the vibrancy losing issue when leaving full screen mode | ||
// @see https://github.com/toeverything/AFFiNE/blob/280e24934a27557529479a70ab38c4f5fc65cb00/packages/frontend/electron/src/main/windows-manager/main-window.ts:L157 | ||
export function refreshBound(window: BrowserWindow, timeout = 0) { | ||
setTimeout(() => { | ||
// FIXME: workaround for theme bug in full screen mode | ||
const size = window?.getSize() | ||
window?.setSize(size[0] + 1, size[1] + 1) | ||
window?.setSize(size[0], size[1]) | ||
}, timeout) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.