Skip to content

Commit

Permalink
💚 添加自动构建后处理脚本,减轻构建包体积
Browse files Browse the repository at this point in the history
  • Loading branch information
hczs committed Oct 10, 2023
1 parent fd32c9e commit f4c0c96
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ jobs:
npm install --legacy-peer-deps
npm run build
- name: Copy pag to target dir
run: node handle_pkg.js

- name: Upload file
uses: actions/upload-artifact@v3
with:
name: kafka-desktop
path: ./release
path: ./release/installation-packages
if-no-files-found: error
38 changes: 38 additions & 0 deletions handle_pkg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const fs = require('fs');
const path = require('path');

// 获取版本号信息
let appVersion = null;
let appName = null;
fs.readFile('./package.json', 'utf-8', (err, data) => {
if (err) {
throw err;
}
const pkg = JSON.parse(data.toString());
appVersion = pkg.version;
appName = pkg.name;

if (appVersion == null) {
throw "版本号解析失败";
}

if (appName == null) {
throw "应用名称解析失败";
}

// 创建 ./release/installation-packages 文件夹
let targetPath = './release/installation-packages/';
fs.mkdirSync(targetPath);

// 从 ./release/${version} 文件夹下取出安装包 放到 ./release/installation-packages 下
let commonPath = "./release/" + appVersion + "/";
let fileName = appName + "_" + appVersion;
let winSourceFile = commonPath + fileName + ".exe";
let macSourceFile = commonPath + fileName + ".dmg";

// 复制文件
fs.copyFileSync(winSourceFile, targetPath + fileName + ".exe");
fs.copyFileSync(macSourceFile, targetPath + fileName + ".dmg");
});


0 comments on commit f4c0c96

Please sign in to comment.