From 8e8feb65c9f301262139aa1062d95670b0fb31f6 Mon Sep 17 00:00:00 2001 From: Flysoft <1922656933@qq.com> Date: Wed, 28 Dec 2022 22:47:25 +0800 Subject: [PATCH] build: improve workflow, change product name --- .github/check-version.js | 70 +++++++++-------- .github/workflows/main.yml | 151 +++++++------------------------------ icalingua/package.json | 8 +- 3 files changed, 71 insertions(+), 158 deletions(-) diff --git a/.github/check-version.js b/.github/check-version.js index 2b08e72ef..6ec4c94c1 100644 --- a/.github/check-version.js +++ b/.github/check-version.js @@ -1,54 +1,62 @@ -const packageJson = require('../icalingua/package.json') -const fs = require('fs') -const core = require('@actions/core') +const packageJson = require("../icalingua/package.json"); +const fs = require("fs"); +const core = require("@actions/core"); Date.prototype.format = function (fmt) { var o = { - 'M+': this.getMonth() + 1, //月份 - 'd+': this.getDate(), //日 - 'h+': this.getHours(), //小时 - 'm+': this.getMinutes(), //分 - 's+': this.getSeconds(), //秒 - 'q+': Math.floor((this.getMonth() + 3) / 3), //季度 + "M+": this.getMonth() + 1, //月份 + "d+": this.getDate(), //日 + "h+": this.getHours(), //小时 + "m+": this.getMinutes(), //分 + "s+": this.getSeconds(), //秒 + "q+": Math.floor((this.getMonth() + 3) / 3), //季度 S: this.getMilliseconds(), //毫秒 - } + }; if (/(y+)/.test(fmt)) { fmt = fmt.replace( RegExp.$1, - (this.getFullYear() + '').substr(4 - RegExp.$1.length), - ) + (this.getFullYear() + "").substr(4 - RegExp.$1.length) + ); } for (var k in o) { - if (new RegExp('(' + k + ')').test(fmt)) { + if (new RegExp("(" + k + ")").test(fmt)) { fmt = fmt.replace( RegExp.$1, - RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length), - ) + RegExp.$1.length === 1 + ? o[k] + : ("00" + o[k]).substr(("" + o[k]).length) + ); } } - return fmt -} + return fmt; +}; -const now = new Date() -const commitId = process.env.SHA.substr(0, 7) -const ref = process.env.REF -const isProduction = ref.startsWith('refs/tags/v') -const buildTime = now.toLocaleString(undefined, {timeZone: 'Asia/Shanghai'}) -const version = process.env.GIT_VER +const now = new Date(); +const commitId = process.env.SHA.substr(0, 7); +const ref = process.env.REF; +const isProduction = ref.startsWith("refs/tags/v"); +const buildTime = now.toLocaleString(undefined, { timeZone: "Asia/Shanghai" }); +const version = process.env.GIT_VER; -packageJson.version = version +packageJson.version = version.replace(".fs.", ""); console.log(`commitId: ${commitId} ref: ${ref} isProduction: ${isProduction} buildTime: ${buildTime} -version: ${version}`) +version: ${version}`); -core.setOutput('arch-version', version.replace(/-/g, '_')) -core.setOutput('pkg-name', `icalingua${isProduction ? '' : '-beta'}`) +core.setOutput("arch-version", version.replace(/-/g, "_")); +core.setOutput("pkg-name", `icalinguim${isProduction ? "" : "-beta"}`); -fs.writeFileSync('icalingua/static/version.json', - JSON.stringify({commitId, ref, isProduction, buildTime, version}), 'utf-8') +fs.writeFileSync( + "icalingua/static/version.json", + JSON.stringify({ commitId, ref, isProduction, buildTime, version }), + "utf-8" +); -fs.writeFileSync('icalingua/package.json', - JSON.stringify(packageJson), 'utf-8') +fs.writeFileSync( + "icalingua/package.json", + JSON.stringify(packageJson), + "utf-8" +); diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 95828a892..8447b0cce 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,63 +5,8 @@ on: - workflow_dispatch jobs: - install: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v3 - - - name: Setup Node.js environment - uses: actions/setup-node@v3 - - - name: Install pnpm - run: corepack enable - - - name: Cache pnpm and node-modules - uses: Icalinguaplusplus/node-pm-action@master - with: - node-modules: ./node_modules - package-manager: pnpm - - - name: pnpm install - run: pnpm install - - pack-bridge-js: - runs-on: ubuntu-20.04 - defaults: - run: - working-directory: icalingua-bridge-oicq - - steps: - - uses: actions/checkout@v3 - - - name: Setup Node.js environment - uses: actions/setup-node@v3 - - - name: Install pnpm - run: corepack enable - - - name: Cache pnpm and node-modules - uses: Icalinguaplusplus/node-pm-action@master - with: - node-modules: ./node_modules - package-manager: pnpm - - - name: pnpm install - run: pnpm install - - - name: Compile - run: pnpm compile - - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: bridge-oicq - path: icalingua-bridge-oicq/build/ - if-no-files-found: error - build-windows-x64: - runs-on: windows-2019 + runs-on: windows-latest outputs: version: ${{ steps.git-ver.outputs.version }} arch-version: ${{ steps.version.outputs.arch-version }} @@ -79,7 +24,13 @@ jobs: - name: Install pnpm run: corepack enable - - name: pnpm install + - name: Cache pnpm and node-modules + uses: Icalinguaplusplus/node-pm-action@master + with: + node-modules: ./node_modules + package-manager: pnpm + + - name: Install deps run: pnpm install - name: Get version tag @@ -91,7 +42,7 @@ jobs: id: version env: SHA: ${{ github.sha }} - REF: ${{ github.REF }} + REF: ${{ github.ref }} GIT_VER: ${{ steps.git-ver.outputs.version }} - name: Build @@ -105,39 +56,20 @@ jobs: - uses: actions/upload-artifact@v3 name: Upload artifact with: - name: Icalingua_Windows64.exe - path: icalingua/build/Icalingua++*.exe + name: exe-x64 + path: icalingua/build/*.exe if-no-files-found: error - install-macos-x64: - runs-on: macos-11 - defaults: - run: - working-directory: icalingua - - steps: - - uses: actions/checkout@v3 - - - name: Setup Node.js environment - uses: actions/setup-node@v3 + - name: Create release + if: startsWith(github.ref, 'refs/tags/v.fs.') + uses: softprops/action-gh-release@v1 with: - node-version: "16" - - - name: Install pnpm - run: corepack enable - - - name: Cache pnpm and node-modules - uses: Icalinguaplusplus/node-pm-action@master - with: - node-modules: ./node_modules - package-manager: pnpm - - - name: pnpm install - run: pnpm install + files: "icalingua/build/*.exe" + generate_release_notes: true + append_body: false build-macos-x64: - runs-on: macos-11 - needs: install-macos-x64 + runs-on: macos-latest outputs: version: ${{ steps.git-ver.outputs.version }} arch-version: ${{ steps.version.outputs.arch-version }} @@ -161,7 +93,7 @@ jobs: node-modules: ./node_modules package-manager: pnpm - - name: pnpm install + - name: Install deps run: pnpm install - name: Get version tag @@ -173,51 +105,24 @@ jobs: id: version env: SHA: ${{ github.sha }} - REF: ${{ github.REF }} + REF: ${{ github.ref }} GIT_VER: ${{ steps.git-ver.outputs.version }} - name: Build run: pnpm build working-directory: icalingua - - name: Rename - run: for i in *.dmg;do mv "$i" "${i%.dmg}_x64.dmg" ;done - working-directory: icalingua/build - - uses: actions/upload-artifact@v3 name: Upload artifact with: - name: Icalingua++_x64.dmg - path: icalingua/build/Icalingua++*.dmg + name: dmg-x64 + path: icalingua/build/*.dmg if-no-files-found: error - release: - runs-on: ubuntu-20.04 - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - needs: - - build-windows-x64 - - build-macos-x64 - steps: - - name: Make dir - run: mkdir release - - - name: Get Icalingua_Windows64.exe - uses: actions/download-artifact@v3 + - name: Create release + if: startsWith(github.ref, 'refs/tags/v.fs.') + uses: softprops/action-gh-release@v1 with: - name: Icalingua_Windows64.exe - path: release - - - name: Get Icalingua++_x64.dmg - uses: actions/download-artifact@v3 - with: - name: Icalingua++_x64.dmg - path: release - - - name: Release - uses: fnkr/github-action-ghr@ghr-options - env: - GHR_PATH: release/ - GITHUB_TOKEN: ${{ github.token }} - GHR_REPLACE: true - GHR_TITLE: ${{ needs.build-dist-bundle.outputs.version }} - GHR_DRAFT: true + files: "icalingua/build/*.dmg" + generate_release_notes: true + append_body: false diff --git a/icalingua/package.json b/icalingua/package.json index dbe46b324..29b2fa6b9 100644 --- a/icalingua/package.json +++ b/icalingua/package.json @@ -25,8 +25,8 @@ "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.ts" }, "build": { - "productName": "Icalingua++", - "appId": "Icalingua++", + "productName": "Icalinguim", + "appId": "Icalinguim", "directories": { "output": "build", "buildResources": "static" @@ -56,10 +56,10 @@ "target": "snap" } ], - "executableName": "icalingua", + "executableName": "icalinguim", "category": "Network", "desktop": { - "StartupWMClass": "icalingua" + "StartupWMClass": "icalinguim" } }, "snap": {