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"); +}); + +