Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add auto updater #105

Merged
merged 1 commit into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
on:
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -59,13 +59,13 @@ jobs:
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
workspaces: "./src-tauri -> target"

- name: Sync node version and setup cache
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'pnpm'
node-version: "16"
cache: "pnpm"

- name: Install app dependencies and build web
run: pnpm install --frozen-lockfile
Expand All @@ -74,9 +74,11 @@ jobs:
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ""
with:
tagName: ${{ github.ref_name }}
releaseName: ChatGPT-Desktop ${{ needs.create-release.outputs.APP_VERSION }}
releaseBody: ''
releaseBody: ""
releaseDraft: true
prerelease: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码看起来没有明显的错误,但是有一些改进建议:

  1. 在字符串使用中保持一致性,要么使用单引号('),要么使用双引号("),不要混合使用。

  2. 在缓存文件路径等地方使用相对路径比较危险,最好使用绝对路径来确保可靠性。

  3. 在发布版本时,最好在 releaseBody 字段中添加一些信息,以便用户了解新版本的变化和更新。

  4. 在使用敏感信息时(如 TAURI_PRIVATE_KEY),最好将它们存储为 GitHub Secrets,并使用 ${{ secrets.XXX }} 语法进行引用。同时,应该考虑为私钥设置密码,以提高安全性。

希望这些建议对你有所帮助!

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ChatGPT-Desktop",
"name": "chatgpt-desktop",
"private": true,
"version": "0.0.7",
"type": "module",
Expand Down Expand Up @@ -70,4 +70,4 @@
"vite": "^4.0.0",
"vue-tsc": "^1.0.11"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个代码补丁主要是修改了一个项目的package.json文件,将项目名称从"ChatGPT-Desktop"改为"chatgpt-desktop"。同时还更新了一些依赖包的版本。

代码看起来没有明显的风险,但建议添加一个末尾的新行(因为最后一行缺少换行符\)以避免一些可能的问题。

此外,可以考虑将其他依赖项升级到其最新版本以提高安全性和稳定性。

23 changes: 22 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chat_gpt"
version = "1.0.0"
version = "0.0.8"
description = "ChatGPT-Desktop"
authors = ["orangelckc", "bilibili-ayang"]
license = "MIT"
Expand All @@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.2", features = [] }

[dependencies]
tauri = { version = "1.2", features = ["api-all", "macos-private-api", "system-tray"] }
tauri = { version = "1.2", features = ["api-all", "macos-private-api", "system-tray", "updater"] }
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个代码补丁主要是更改了包名和版本号,并添加了一个更新插件。

从代码上来看,没有明显的潜在风险,这只是一些简单的更改。不过,如果是一份关键性的生产代码,则需要做更加彻底的代码审查。

对于改进建议,我建议将依赖项的版本号锁定到确切的版本,而不是使用通配符,这可以确保在以后进行构建时,所使用的依赖项版本与最初的版本一致。

Expand Down
13 changes: 7 additions & 6 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
"icons/icon.icns",
"icons/icon.ico"
],
"targets": [
"deb",
"msi",
"dmg"
],
"targets": "all",
"identifier": "com.ChatGPT-Desktop",
"macOS": {
"entitlements": null,
Expand All @@ -71,7 +67,12 @@
"csp": null
},
"updater": {
"active": false
"active": true,
"dialog": true,
"endpoints": [
"https://updater-two.vercel.app/update/{{target}}/{{current_version}}"
],
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDhDRkYzMDc2NTFGRTQ5MTIKUldRU1NmNVJkakQvaklIVnpidTB5TVBwUXlFOTI1WkJwS0h4YTJScEdxQ0lzRkFnQUhDQ3pnM28K"
},
"windows": [
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码的更改相对较小,主要是修改了 "targets" 部分和更新器的配置。以下是我的反馈:

  • "targets" 的更改将打包目标设置为“所有”,这意味着应用程序将在 deb、msi 和 dmg 格式中生成。这种更改不会引入错误风险。
  • 更新器现在是活动状态,并配置了对话框和公钥等属性。这可能会增加一些安全风险,但可以提高用户体验并使应用程序更易于维护。

在更新器的配置中,建议添加一个备份的 endpoint 以防止原始 endpoint 不可用时无法提供更新。

此外,在任何更改后都必须执行充分的测试来确保应用程序在各种环境中正常工作。

Expand Down