mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 20:12:48 +00:00
perf: 优化客户端升级
This commit is contained in:
parent
ee7a1bd99c
commit
9296008ecc
59
.github/workflows/publish.yml
vendored
59
.github/workflows/publish.yml
vendored
@ -125,16 +125,10 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- platform: "macos-12"
|
- platform: "macos-12"
|
||||||
build_type: "mac"
|
build_type: "mac"
|
||||||
args: "--target aarch64-apple-darwin"
|
|
||||||
- platform: "macos-12"
|
|
||||||
build_type: "mac"
|
|
||||||
args: "--target x86_64-apple-darwin"
|
|
||||||
- platform: "ubuntu-latest"
|
- platform: "ubuntu-latest"
|
||||||
build_type: "android"
|
build_type: "android"
|
||||||
args: ""
|
|
||||||
- platform: "windows-latest"
|
- platform: "windows-latest"
|
||||||
build_type: "windows"
|
build_type: "windows"
|
||||||
args: ""
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
environment: build
|
environment: build
|
||||||
@ -153,7 +147,7 @@ jobs:
|
|||||||
uses: nick-fields/retry@v2
|
uses: nick-fields/retry@v2
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 10
|
timeout_minutes: 10
|
||||||
max_attempts: 5
|
max_attempts: 3
|
||||||
command: |
|
command: |
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update --remote "resources/mobile"
|
git submodule update --remote "resources/mobile"
|
||||||
@ -170,8 +164,8 @@ jobs:
|
|||||||
if: matrix.build_type == 'android'
|
if: matrix.build_type == 'android'
|
||||||
uses: nick-fields/retry@v2
|
uses: nick-fields/retry@v2
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 60
|
timeout_minutes: 20
|
||||||
max_attempts: 10
|
max_attempts: 5
|
||||||
command: |
|
command: |
|
||||||
cd resources/mobile/platforms/android/eeuiApp
|
cd resources/mobile/platforms/android/eeuiApp
|
||||||
chmod +x ./gradlew
|
chmod +x ./gradlew
|
||||||
@ -180,20 +174,35 @@ jobs:
|
|||||||
- name: (Android) Upload File
|
- name: (Android) Upload File
|
||||||
if: matrix.build_type == 'android'
|
if: matrix.build_type == 'android'
|
||||||
env:
|
env:
|
||||||
DP_KEY: ${{ secrets.DP_KEY }}
|
PUBLISH_KEY: ${{ secrets.PUBLISH_KEY }}
|
||||||
run: |
|
run: |
|
||||||
node ./electron/build.js android-upload
|
node ./electron/build.js android-upload
|
||||||
|
|
||||||
- name: (Android) Upload Release
|
- name: (Android) Upload Release
|
||||||
if: matrix.build_type == 'android'
|
if: matrix.build_type == 'android'
|
||||||
|
uses: actions/github-script@v7
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ needs.check-version.outputs.version }}
|
script: |
|
||||||
draft: true
|
const fs = require('fs');
|
||||||
files: |
|
const path = require('path');
|
||||||
resources/mobile/platforms/android/eeuiApp/app/build/outputs/apk/release/*.apk
|
const globby = require('globby');
|
||||||
|
|
||||||
|
// 查找 APK 文件
|
||||||
|
const files = await globby('resources/mobile/platforms/android/eeuiApp/app/build/outputs/apk/release/*.apk');
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const data = await fs.promises.readFile(file);
|
||||||
|
|
||||||
|
await github.rest.repos.uploadReleaseAsset({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
release_id: process.env.RELEASE_ID,
|
||||||
|
name: path.basename(file),
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
# Mac 构建步骤
|
# Mac 构建步骤
|
||||||
- name: (Mac) Build Client
|
- name: (Mac) Build Client
|
||||||
@ -203,9 +212,9 @@ jobs:
|
|||||||
APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
|
APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
|
||||||
CSC_LINK: ${{ secrets.CSC_LINK }}
|
CSC_LINK: ${{ secrets.CSC_LINK }}
|
||||||
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
|
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
|
||||||
DP_KEY: ${{ secrets.DP_KEY }}
|
PUBLISH_KEY: ${{ secrets.PUBLISH_KEY }}
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GH_REPOSITORY: ${{ github.repository }}
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
./cmd electron mac
|
./cmd electron mac
|
||||||
|
|
||||||
@ -213,15 +222,15 @@ jobs:
|
|||||||
- name: (Windows) Build Client
|
- name: (Windows) Build Client
|
||||||
if: matrix.build_type == 'windows'
|
if: matrix.build_type == 'windows'
|
||||||
env:
|
env:
|
||||||
DP_KEY: ${{ secrets.DP_KEY }}
|
PUBLISH_KEY: ${{ secrets.PUBLISH_KEY }}
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GH_REPOSITORY: ${{ github.repository }}
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
./cmd electron win
|
./cmd electron win
|
||||||
|
|
||||||
# publish-release:
|
# publish-release:
|
||||||
# needs: [check-version, create-release, builds]
|
# needs: [check-version, create-release, build-client]
|
||||||
# if: needs.check-version.outputs.should_release == 'true'
|
# if: needs.check-version.outputs.should_release == 'true'
|
||||||
# permissions:
|
# permissions:
|
||||||
# contents: write
|
# contents: write
|
||||||
@ -232,13 +241,13 @@ jobs:
|
|||||||
# id: publish-release
|
# id: publish-release
|
||||||
# uses: actions/github-script@v7
|
# uses: actions/github-script@v7
|
||||||
# env:
|
# env:
|
||||||
# release_id: ${{ needs.create-release.outputs.release_id }}
|
# RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
|
||||||
# with:
|
# with:
|
||||||
# script: |
|
# script: |
|
||||||
# github.rest.repos.updateRelease({
|
# github.rest.repos.updateRelease({
|
||||||
# owner: context.repo.owner,
|
# owner: context.repo.owner,
|
||||||
# repo: context.repo.repo,
|
# repo: context.repo.repo,
|
||||||
# release_id: process.env.release_id,
|
# release_id: process.env.RELEASE_ID,
|
||||||
# draft: false,
|
# draft: false,
|
||||||
# prerelease: false
|
# prerelease: false
|
||||||
# })
|
# })
|
||||||
|
|||||||
@ -4,15 +4,15 @@
|
|||||||
|
|
||||||
1. 添加环境变量 `APPLEID`、`APPLEIDPASS` 用于公证
|
1. 添加环境变量 `APPLEID`、`APPLEIDPASS` 用于公证
|
||||||
2. 添加环境变量 `CSC_LINK`、`CSC_KEY_PASSWORD` 用于签名
|
2. 添加环境变量 `CSC_LINK`、`CSC_KEY_PASSWORD` 用于签名
|
||||||
3. 添加环境变量 `GH_TOKEN`、`GH_REPOSITORY` 用于发布到GitHub
|
3. 添加环境变量 `GITHUB_TOKEN`、`GITHUB_REPOSITORY` 用于发布到GitHub(GitHub Actions 发布不需要)
|
||||||
4. 添加环境变量 `DP_KEY` 用于发布到私有服务器
|
4. 添加环境变量 `PUBLISH_KEY` 用于发布到私有服务器
|
||||||
|
|
||||||
## 通过 GitHub Actions 发布
|
## 通过 GitHub Actions 发布
|
||||||
|
|
||||||
1. 执行 `npm run version` 生成版本
|
1. 执行 `npm run version` 生成版本
|
||||||
2. 执行 `npm run build` 编译前端
|
2. 执行 `npm run build` 编译前端
|
||||||
3. 执行 `git commit` 提交并推送
|
3. 执行 `git commit` 提交并推送
|
||||||
4. 添加并推送标签
|
4. 等待 GitHub Actions 自动发布
|
||||||
|
|
||||||
## 本地发布
|
## 本地发布
|
||||||
|
|
||||||
@ -22,5 +22,5 @@
|
|||||||
|
|
||||||
## 编译App
|
## 编译App
|
||||||
|
|
||||||
1. 执行 `./cmd appbuild [setting]` 编译
|
1. 执行 `./cmd appbuild publish` 编译
|
||||||
2. 进入 `resources/mobile` eeui框架内打包Android或iOS应用
|
2. 进入 `resources/mobile` eeui框架内打包Android或iOS应用
|
||||||
|
|||||||
40
electron/build.js
vendored
40
electron/build.js
vendored
@ -11,7 +11,7 @@ const utils = require('./utils');
|
|||||||
const config = require('../package.json')
|
const config = require('../package.json')
|
||||||
const env = require('dotenv').config({ path: './.env' })
|
const env = require('dotenv').config({ path: './.env' })
|
||||||
const argv = process.argv;
|
const argv = process.argv;
|
||||||
const {APPLEID, APPLEIDPASS, GH_TOKEN, GH_REPOSITORY, DP_KEY} = process.env;
|
const {APPLEID, APPLEIDPASS, GITHUB_TOKEN, GITHUB_REPOSITORY, PUBLISH_KEY} = process.env;
|
||||||
|
|
||||||
const electronDir = path.resolve(__dirname, "public");
|
const electronDir = path.resolve(__dirname, "public");
|
||||||
const nativeCachePath = path.resolve(__dirname, ".native");
|
const nativeCachePath = path.resolve(__dirname, ".native");
|
||||||
@ -37,9 +37,9 @@ async function detectAndDownloadUpdater() {
|
|||||||
// 获取最新release
|
// 获取最新release
|
||||||
const spinner = ora('检查更新器...').start();
|
const spinner = ora('检查更新器...').start();
|
||||||
const response = await axios.get('https://api.github.com/repos/kuaifan/dootask-updater/releases/latest', {
|
const response = await axios.get('https://api.github.com/repos/kuaifan/dootask-updater/releases/latest', {
|
||||||
headers: GH_TOKEN ? { 'Authorization': `token ${GH_TOKEN}` } : {}
|
headers: GITHUB_TOKEN ? { 'Authorization': `token ${GITHUB_TOKEN}` } : {}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.data || !response.data.assets) {
|
if (!response.data || !response.data.assets) {
|
||||||
spinner.fail('检查更新器失败');
|
spinner.fail('检查更新器失败');
|
||||||
return;
|
return;
|
||||||
@ -67,7 +67,7 @@ async function detectAndDownloadUpdater() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 过滤出binary开头的zip文件
|
// 过滤出binary开头的zip文件
|
||||||
const assets = response.data.assets.filter(asset =>
|
const assets = response.data.assets.filter(asset =>
|
||||||
asset.name.startsWith('binary_') && asset.name.endsWith('.zip')
|
asset.name.startsWith('binary_') && asset.name.endsWith('.zip')
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ async function detectAndDownloadUpdater() {
|
|||||||
if (!match) continue;
|
if (!match) continue;
|
||||||
|
|
||||||
let [, platform, arch] = match;
|
let [, platform, arch] = match;
|
||||||
|
|
||||||
// 平台名称映射
|
// 平台名称映射
|
||||||
const platformMap = {
|
const platformMap = {
|
||||||
'macos': 'mac',
|
'macos': 'mac',
|
||||||
@ -114,7 +114,7 @@ async function detectAndDownloadUpdater() {
|
|||||||
url: asset.browser_download_url,
|
url: asset.browser_download_url,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
headers: GH_TOKEN ? { 'Authorization': `token ${GH_TOKEN}` } : {}
|
headers: GITHUB_TOKEN ? { 'Authorization': `token ${GITHUB_TOKEN}` } : {}
|
||||||
});
|
});
|
||||||
|
|
||||||
response.data.pipe(writer);
|
response.data.pipe(writer);
|
||||||
@ -129,7 +129,7 @@ async function detectAndDownloadUpdater() {
|
|||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
yauzl.open(zipPath, { lazyEntries: true }, (err, zipfile) => {
|
yauzl.open(zipPath, { lazyEntries: true }, (err, zipfile) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
|
|
||||||
zipfile.readEntry();
|
zipfile.readEntry();
|
||||||
zipfile.on('entry', (entry) => {
|
zipfile.on('entry', (entry) => {
|
||||||
if (/\/$/.test(entry.fileName)) {
|
if (/\/$/.test(entry.fileName)) {
|
||||||
@ -137,7 +137,7 @@ async function detectAndDownloadUpdater() {
|
|||||||
} else {
|
} else {
|
||||||
zipfile.openReadStream(entry, (err, readStream) => {
|
zipfile.openReadStream(entry, (err, readStream) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
|
|
||||||
const outputPath = path.join(targetDir, path.basename(entry.fileName));
|
const outputPath = path.join(targetDir, path.basename(entry.fileName));
|
||||||
const writer = fs.createWriteStream(outputPath);
|
const writer = fs.createWriteStream(outputPath);
|
||||||
readStream.pipe(writer);
|
readStream.pipe(writer);
|
||||||
@ -148,7 +148,7 @@ async function detectAndDownloadUpdater() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
zipfile.on('end', resolve);
|
zipfile.on('end', resolve);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -270,8 +270,8 @@ function axiosAutoTry(data) {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
function androidUpload(url) {
|
function androidUpload(url) {
|
||||||
if (!DP_KEY) {
|
if (!PUBLISH_KEY) {
|
||||||
console.error("缺少 Deploy Key, 请检查环境变量!");
|
console.error("缺少 PUBLISH_KEY 环境变量");
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
const releaseDir = path.resolve(__dirname, "../resources/mobile/platforms/android/eeuiApp/app/build/outputs/apk/release");
|
const releaseDir = path.resolve(__dirname, "../resources/mobile/platforms/android/eeuiApp/app/build/outputs/apk/release");
|
||||||
@ -300,7 +300,7 @@ function androidUpload(url) {
|
|||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
'Publish-Version': config.version,
|
'Publish-Version': config.version,
|
||||||
'Publish-Key': DP_KEY,
|
'Publish-Key': PUBLISH_KEY,
|
||||||
'Content-Type': 'multipart/form-data;boundary=' + formData.getBoundary(),
|
'Content-Type': 'multipart/form-data;boundary=' + formData.getBoundary(),
|
||||||
},
|
},
|
||||||
onUploadProgress: progress => {
|
onUploadProgress: progress => {
|
||||||
@ -556,8 +556,8 @@ async function startBuild(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
// github (build && publish)
|
// github (build && publish)
|
||||||
if (publish === true && GH_TOKEN && utils.strExists(GH_REPOSITORY, "/")) {
|
if (publish === true && GITHUB_TOKEN && utils.strExists(GITHUB_REPOSITORY, "/")) {
|
||||||
const repository = GH_REPOSITORY.split("/")
|
const repository = GITHUB_REPOSITORY.split("/")
|
||||||
econfig.build.publish = {
|
econfig.build.publish = {
|
||||||
"releaseType": "release",
|
"releaseType": "release",
|
||||||
"provider": "github",
|
"provider": "github",
|
||||||
@ -573,10 +573,10 @@ async function startBuild(data) {
|
|||||||
econfig.build.directories.output = `${output}-generic`;
|
econfig.build.directories.output = `${output}-generic`;
|
||||||
fs.writeFileSync(packageFile, JSON.stringify(econfig, null, 4), 'utf8');
|
fs.writeFileSync(packageFile, JSON.stringify(econfig, null, 4), 'utf8');
|
||||||
child_process.execSync(`npm run ${platform}`, {stdio: "inherit", cwd: "electron"});
|
child_process.execSync(`npm run ${platform}`, {stdio: "inherit", cwd: "electron"});
|
||||||
if (publish === true && DP_KEY) {
|
if (publish === true && PUBLISH_KEY) {
|
||||||
genericPublish({
|
genericPublish({
|
||||||
url: econfig.build.publish.url,
|
url: econfig.build.publish.url,
|
||||||
key: DP_KEY,
|
key: PUBLISH_KEY,
|
||||||
version: config.version,
|
version: config.version,
|
||||||
output: econfig.build.directories.output
|
output: econfig.build.directories.output
|
||||||
})
|
})
|
||||||
@ -649,7 +649,7 @@ if (["dev"].includes(argv[2])) {
|
|||||||
name: "MacOS",
|
name: "MacOS",
|
||||||
value: platforms[0],
|
value: platforms[0],
|
||||||
checked: true
|
checked: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Windows",
|
name: "Windows",
|
||||||
value: platforms[1]
|
value: platforms[1]
|
||||||
@ -671,7 +671,7 @@ if (["dev"].includes(argv[2])) {
|
|||||||
name: "arm64",
|
name: "arm64",
|
||||||
value: architectures[0],
|
value: architectures[0],
|
||||||
checked: true
|
checked: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "x64",
|
name: "x64",
|
||||||
value: architectures[1]
|
value: architectures[1]
|
||||||
@ -734,8 +734,8 @@ if (["dev"].includes(argv[2])) {
|
|||||||
const publishAnswers = await inquirer.prompt(publishQuestions);
|
const publishAnswers = await inquirer.prompt(publishQuestions);
|
||||||
Object.assign(answers, publishAnswers);
|
Object.assign(answers, publishAnswers);
|
||||||
|
|
||||||
if (!DP_KEY && (!GH_TOKEN || !utils.strExists(GH_REPOSITORY, "/"))) {
|
if (!PUBLISH_KEY && (!GITHUB_TOKEN || !utils.strExists(GITHUB_REPOSITORY, "/"))) {
|
||||||
console.error("发布需要 Deploy Key 或 GitHub Token 和 Repository, 请检查环境变量!");
|
console.error("发布需要 PUBLISH_KEY 或 GitHub Token 和 Repository, 请检查环境变量!");
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user