This repository has been archived by the owner on Jun 18, 2023. It is now read-only.
forked from Icalingua-plus-plus/Icalingua-plus-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: improve workflow, change product name
- Loading branch information
1 parent
32294f4
commit 8e8feb6
Showing
3 changed files
with
71 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters