Feat: publish to s3 & auto update (#511)

* publish to s3

* add update base url

* autoupdate from s3

* fix warning

* update locales

* update publish workflow
This commit is contained in:
an-lee
2024-04-11 21:37:48 +08:00
committed by GitHub
parent b4767a9c7a
commit 39c55b5f3f
11 changed files with 888 additions and 31 deletions

View File

@@ -30,6 +30,9 @@ jobs:
APPLE_ID: ${{ runner.os == 'macOS' && secrets.APPLE_ID || '' }}
APPLE_APP_PASSWORD: ${{ runner.os == 'macOS' && secrets.APPLE_APP_PASSWORD || '' }}
APPLE_TEAM_ID: ${{ runner.os == 'macOS' && secrets.APPLE_TEAM_ID || '' }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
run: yarn enjoy:publish
- name: Upload artifact

View File

@@ -35,8 +35,15 @@ const config = {
new MakerSquirrel({
name: "Enjoy",
setupIcon: "./assets/icon.ico",
config: (arch) => ({
remoteReleases: `https://dl.enjoy.bot/enjoy-updates/win32/${arch}`,
}),
}),
new MakerZIP({
config: (arch) => ({
macUpdateManifestBaseUrl: `https://dl.enjoy.bot/enjoy-updates/darwin/${arch}`,
}),
}),
new MakerZIP(["win32"]),
new MakerDeb({
options: {
name: "enjoy",
@@ -54,19 +61,7 @@ const config = {
// },
// }),
],
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
repository: {
owner: "xiaolai",
name: "everyone-can-use-english",
},
generateReleaseNotes: true,
draft: true,
},
},
],
publishers: [],
plugins: [
new VitePlugin({
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
@@ -129,4 +124,42 @@ if (
};
}
if (process.env.GITHUB_TOKEN) {
config.publishers = [
...config.publishers,
{
name: "@electron-forge/publisher-github",
config: {
repository: {
owner: "xiaolai",
name: "everyone-can-use-english",
},
generateReleaseNotes: true,
draft: true,
},
},
];
}
if (
process.env.S3_ACCESS_KEY_ID &&
process.env.S3_SECRET_ACCESS_KEY &&
process.env.S3_ENDPOINT
) {
config.publishers = [
...config.publishers,
{
name: "@electron-forge/publisher-s3",
config: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
endpoint: process.env.S3_ENDPOINT,
bucket: "download",
region: "auto",
public: true,
},
},
];
}
export default config;

View File

@@ -81,6 +81,7 @@
},
"dependencies": {
"@andrkrn/ffprobe-static": "^5.2.0",
"@electron-forge/publisher-s3": "^7.3.1",
"@hookform/resolvers": "^3.3.4",
"@langchain/community": "^0.0.43",
"@langchain/google-genai": "^0.0.10",
@@ -168,6 +169,7 @@
"sqlite3": "^5.1.7",
"tailwind-scrollbar-hide": "^1.1.7",
"umzug": "^3.8.0",
"update-electron-app": "^3.0.0",
"wavesurfer.js": "^7.7.10",
"zod": "^3.22.4"
}

View File

@@ -261,6 +261,7 @@
"about": "About",
"currentVersion": "Current version",
"checkUpdate": "Check update",
"checkingLatestVersion": "Checking latest version",
"userGuide": "User guide",
"feedback": "Feedback",
"alreadyLatestVersion": "Already latest version",

View File

@@ -261,6 +261,7 @@
"about": "关于",
"currentVersion": "当前版本",
"checkUpdate": "检查更新",
"checkingLatestVersion": "正在检查最新版本",
"userGuide": "用户指南",
"feedback": "反馈",
"alreadyLatestVersion": "已经是最新版本",

View File

@@ -23,6 +23,7 @@ import { Waveform } from "./waveform";
import url from "url";
import echogarden from "./echogarden";
import camdict from "./camdict";
import { updateElectronApp, UpdateSourceType } from "update-electron-app";
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -386,6 +387,15 @@ ${log}
);
});
ipcMain.handle("app-update", () => {
return updateElectronApp({
updateSource: {
type: UpdateSourceType.StaticStorage,
baseUrl: `https://dl.enjoy.bot/enjoy-updates/${process.platform}/${process.arch}`,
},
});
});
ipcMain.handle(
"system-preferences-media-access",
async (_event, mediaType: "microphone" | "camera") => {
@@ -446,7 +456,7 @@ ${log}
icon: "./assets/icon.png",
width: 1280,
height: 720,
minWidth: 720 ,
minWidth: 720,
minHeight: 576,
webPreferences: {
preload: path.join(__dirname, "preload.js"),

View File

@@ -32,6 +32,9 @@ contextBridge.exposeInMainWorld("__ENJOY_APP__", {
createIssue: (title: string, body: string) => {
return ipcRenderer.invoke("app-create-issue", title, body);
},
update: () => {
return ipcRenderer.invoke("app-update");
},
version,
},
window: {

View File

@@ -1,11 +1,23 @@
import { t } from "i18next";
import { Button, Separator } from "@renderer/components/ui";
import { Button, Separator, toast } from "@renderer/components/ui";
import { AppSettingsProviderContext } from "@renderer/context";
import { useContext } from "react";
export const About = () => {
const { version, EnjoyApp } = useContext(AppSettingsProviderContext);
const checkUpdate = async () => {
toast.promise(
EnjoyApp.app.update().catch((error) => {
toast.error(error);
EnjoyApp.shell.openExternal("https://1000h.org/enjoy-app/install.html");
}),
{
loading: t("checkingLatestVersion"),
}
);
};
return (
<>
<div className="font-semibold mb-4 capitilized">{t("about")}</div>
@@ -15,15 +27,7 @@ export const About = () => {
<div className="mb-2">{t("currentVersion")}</div>
<div className="text-sm text-muted-foreground mb-2">v{version}</div>
</div>
<Button
onClick={() => {
EnjoyApp.shell.openExternal(
"https://github.com/xiaolai/everyone-can-use-english/releases/latest"
);
}}
>
{t("checkUpdate")}
</Button>
<Button onClick={checkUpdate}>{t("checkUpdate")}</Button>
</div>
<Separator />

View File

@@ -29,7 +29,7 @@ export const ThemeSettings = () => {
}}
>
<SelectTrigger className="text-xs">
<SelectValue asChild>
<SelectValue>
<Button variant="ghost" size="icon">
<SunIcon className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<MoonIcon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
@@ -37,6 +37,7 @@ export const ThemeSettings = () => {
</Button>
</SelectValue>
</SelectTrigger>
<SelectContent>
<SelectItem className="text-xs" value="light">
{t("light")}

View File

@@ -9,6 +9,7 @@ type EnjoyAppType = {
quit: () => Promise<void>;
openDevTools: () => Promise<void>;
createIssue: (title: string, body: string) => Promise<void>;
update: () => Promise<void>;
version: string;
};
window: {

808
yarn.lock

File diff suppressed because it is too large Load Diff