From f4c0c96987906a5687d24b8e0483c2bf8596484b Mon Sep 17 00:00:00 2001 From: sunny Date: Tue, 10 Oct 2023 23:26:53 +0800 Subject: [PATCH] =?UTF-8?q?:green=5Fheart:=20=E6=B7=BB=E5=8A=A0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=9E=84=E5=BB=BA=E5=90=8E=E5=A4=84=E7=90=86=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E5=87=8F=E8=BD=BB=E6=9E=84=E5=BB=BA=E5=8C=85?= =?UTF-8?q?=E4=BD=93=E7=A7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 5 ++++- handle_pkg.js | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 handle_pkg.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85c4efb..eb216d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/handle_pkg.js b/handle_pkg.js new file mode 100644 index 0000000..befe1c2 --- /dev/null +++ b/handle_pkg.js @@ -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"); +}); + +