Skip to content

Commit 123d22e

Browse files
committed
feat: updater
1 parent 58ac49d commit 123d22e

File tree

10 files changed

+368
-34
lines changed

10 files changed

+368
-34
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,24 @@ jobs:
8888
- uses: tauri-apps/tauri-action@v0
8989
env:
9090
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
92+
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
9193
with:
9294
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
95+
96+
updater:
97+
runs-on: ubuntu-latest
98+
needs: [create-release, build-tauri]
99+
100+
steps:
101+
- uses: actions/setup-node@v2
102+
with:
103+
node-version: '14'
104+
- run: yarn updater -v=${{ needs.create-release.steps.get_version.outputs.VERSION }}
105+
106+
- name: Deploy
107+
uses: peaceiris/actions-gh-pages@v3
108+
with:
109+
github_token: ${{ secrets.GITHUB_TOKEN }}
110+
publish_dir: ./updater
111+
force_orphan: true

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"build": "rsw build && tsc && vite build",
99
"preview": "vite preview",
1010
"tauri": "tauri",
11-
"rsw": "rsw"
11+
"rsw": "rsw",
12+
"updater": "esno ./scripts/updater.ts"
1213
},
1314
"dependencies": {
1415
"@floating-ui/react-dom-interactions": "^0.6.0",
@@ -17,7 +18,7 @@
1718
"@iconify-icons/mdi": "^1.2.11",
1819
"@iconify/react": "^3.2.1",
1920
"@monaco-editor/react": "^4.4.5",
20-
"@tauri-apps/api": "^1.0.2",
21+
"@tauri-apps/api": "^1.1.0",
2122
"allotment": "^1.17.0",
2223
"clsx": "^1.1.1",
2324
"dayjs": "^1.11.2",
@@ -42,10 +43,14 @@
4243
"@types/highlight.js": "^10.1.0",
4344
"@types/lodash": "^4.14.182",
4445
"@types/markdown-it": "^12.2.3",
46+
"@types/minimist": "^1.2.2",
47+
"@types/node": "^18.7.23",
4548
"@types/react": "^18.0.0",
4649
"@types/react-dom": "^18.0.0",
4750
"@types/uuid": "^8.3.4",
4851
"@vitejs/plugin-react": "^2.0.0",
52+
"esno": "^0.16.3",
53+
"minimist": "^1.2.6",
4954
"sass": "^1.53.0",
5055
"typescript": "^4.6.3",
5156
"unocss": "^0.33.2",

scripts/updater.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import minimist from 'minimist';
2+
import fs from 'fs';
3+
4+
const argv = minimist(process.argv.slice(2));
5+
6+
if (!argv.v) {
7+
console.log('Missing version');
8+
process.exit(1);
9+
}
10+
11+
const baseURL = `https://github.com/lencx/OhMyBox/releases/download/v${argv.v}`;
12+
13+
// https://github.com/lencx/OhMyBox/releases
14+
// Darwin
15+
// /src-tauri/target/release/bundle/macos/OhMyBox.dmg
16+
// /src-tauri/target/release/bundle/macos/OhMyBox.app.tar.gz
17+
// Linux
18+
// /src-tauri/target/release/bundle/appimage/oh-my-box_0.1.1_amd64.AppImage
19+
// /src-tauri/target/release/bundle/appimage/oh-my-box_0.1.1_amd64.AppImage.tar.gz
20+
// Windows
21+
// \src-tauri\target\release\bundle\msi\OhMyBox_0.1.1_x64_en-US.msi
22+
// \src-tauri\target\release\bundle\msi\OhMyBox_0.1.1_x64_en-US.msi.zip
23+
const updaterInfo = {
24+
version: `v${argv.v}`,
25+
notes: `OhMyBox version`,
26+
pub_date: new Date(),
27+
platforms: {
28+
'darwin-x86_64': {
29+
signature: '',
30+
url: `${baseURL}/OhMyBox.app.tar.gz`
31+
},
32+
'darwin-aarch64': {
33+
signature: '',
34+
url: `${baseURL}/OhMyBox.app.tar.gz`
35+
},
36+
'linux-x86_64': {
37+
signature: '',
38+
url: `${baseURL}/oh-my-box_${argv.v}_amd64.AppImage`
39+
},
40+
'windows-x86_64': {
41+
signature: '',
42+
url: `${baseURL}/OhMyBox_${argv.v}_x64_en-US.msi`
43+
}
44+
}
45+
}
46+
47+
if (!fs.existsSync('updater')) {
48+
fs.mkdirSync('updater');
49+
}
50+
51+
fs.writeFileSync('./updater/app.json', JSON.stringify(updaterInfo, null, 2));

src-tauri/Cargo.lock

Lines changed: 35 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ rust-version = "1.57"
1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313

1414
[build-dependencies]
15-
tauri-build = { version = "1.1.0", features = [] }
15+
tauri-build = { version = "1.1.1", features = [] }
1616

1717
[dependencies]
1818
serde_json = "1.0"
1919
serde = { version = "1.0", features = ["derive"] }
20-
tauri = { version = "1.1.0", features = ["api-all", "icon-png", "macos-private-api", "system-tray"] }
20+
tauri = { version = "1.1.1", features = ["api-all", "icon-png", "macos-private-api", "system-tray", "updater"] }
2121
thiserror = "1.0"
2222
window-vibrancy = "0.2.0"
2323

src-tauri/tauri.conf.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
"withGlobalTauri": true
1313
},
1414
"tauri": {
15+
"updater": {
16+
"active": true,
17+
"dialog": true,
18+
"endpoints": ["https://lencx.github.io/OhMyBox/app.json"],
19+
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU5MEIwREEzNDlBNzdDN0MKUldSOGZLZEpvdzBMNmFOZ2cyY2NPeTdwK2hsV3gwcWxoZHdUWXRZWFBpQTh1dWhqWXhBdkl0cW8K"
20+
},
1521
"systemTray": {
1622
"iconPath": "icons/icon.png",
1723
"iconAsTemplate": true
@@ -59,9 +65,6 @@
5965
"security": {
6066
"csp": null
6167
},
62-
"updater": {
63-
"active": false
64-
},
6568
"windows": [
6669
{
6770
"width": 800,

src/views/dashboard/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
// import { useEffect } from 'react';
2-
// import path from '@tauri-apps/api/path';
3-
4-
import OmbCard, { OmbItem, OmbIcon } from '@/components/OmbCard';
1+
import OmbCard, { OmbIcon } from '@/components/OmbCard';
52
import SwitchLang from '@/components/SwitchLang';
6-
import useI18n from '@/hooks/useI18n';
7-
// import ohmyboxIcon from '@/oh-my-box.svg';
3+
// import useI18n from '@/hooks/useI18n';
84

95
export default function DashboardView() {
10-
const t = useI18n(['dashboard', 'tools', 'game']);
6+
// const t = useI18n(['dashboard', 'tools', 'game']);
117

128
return (
139
<div className="p-5">

updater/app.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "v123",
3+
"notes": "OhMyBox version",
4+
"pub_date": "2022-10-01T14:05:35.390Z",
5+
"platforms": {
6+
"darwin-x86_64": {
7+
"signature": "",
8+
"url": "https://github.com/lencx/OhMyBox/releases/download/v123//OhMyBox.app.tar.gz"
9+
},
10+
"darwin-aarch64": {
11+
"signature": "",
12+
"url": "https://github.com/lencx/OhMyBox/releases/download/v123//OhMyBox.app.tar.gz"
13+
},
14+
"linux-x86_64": {
15+
"signature": "",
16+
"url": "https://github.com/lencx/OhMyBox/releases/download/v123//oh-my-box_123_amd64.AppImage"
17+
},
18+
"windows-x86_64": {
19+
"signature": "",
20+
"url": "https://github.com/lencx/OhMyBox/releases/download/v123//OhMyBox_123_x64_en-US.msi"
21+
}
22+
}
23+
}

vite.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ export default defineConfig({
1818
rollupOptions: {
1919
output: {
2020
manualChunks: {
21+
highlight: ['highlight.js'],
2122
utils: ['lodash', 'uuid', 'dayjs', 'clsx'],
22-
react: ['react', 'react-dom', 'react-router-dom'],
23-
i18next: ['i18next', 'react-i18next'],
23+
comps: ['react-colorful', '@floating-ui/react-dom-interactions', 'allotment', 'framer-motion', 'rc-slider'],
24+
react: ['react', 'react-dom', 'react-router-dom', '@iconify/react', '@monaco-editor/react', 'jotai'],
25+
i18next: ['i18next', 'react-i18next', 'i18next-browser-languagedetector'],
26+
md: ['markdown-it', 'github-markdown-css'],
2427
}
2528
}
2629
}

0 commit comments

Comments
 (0)