Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
build: improve workflow, change product name
Browse files Browse the repository at this point in the history
  • Loading branch information
FlysoftBeta committed Dec 28, 2022
1 parent 32294f4 commit 8e8feb6
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 158 deletions.
70 changes: 39 additions & 31 deletions .github/check-version.js
Original file line number Diff line number Diff line change
@@ -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"
);
151 changes: 28 additions & 123 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions icalingua/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -56,10 +56,10 @@
"target": "snap"
}
],
"executableName": "icalingua",
"executableName": "icalinguim",
"category": "Network",
"desktop": {
"StartupWMClass": "icalingua"
"StartupWMClass": "icalinguim"
}
},
"snap": {
Expand Down

0 comments on commit 8e8feb6

Please sign in to comment.