mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
feat: 自动化版本发布控制
This commit is contained in:
parent
6f053f5f7d
commit
b83229b5da
@ -4,16 +4,27 @@ const process = require("process");
|
||||
console.log("[NapCat] [CheckVersion] 开始检测当前仓库版本...");
|
||||
try {
|
||||
const packageJson = require("../package.json");
|
||||
const manifsetJson = require("../manifest.json");
|
||||
|
||||
const currentVersion = packageJson.version;
|
||||
const targetVersion = process.env.VERSION;
|
||||
|
||||
const manifestCurrentVersion = manifsetJson.version;
|
||||
const manifestTargetVersion = process.env.VERSION;
|
||||
|
||||
console.log("[NapCat] [CheckVersion] currentVersion:", currentVersion, "targetVersion:", targetVersion);
|
||||
console.log("[NapCat] [CheckVersion] manifestCurrentVersion:", manifestCurrentVersion, "manifestTargetVersion:", manifestTargetVersion);
|
||||
|
||||
// 验证 targetVersion 格式
|
||||
if (!targetVersion || typeof targetVersion !== 'string') {
|
||||
console.log("[NapCat] [CheckVersion] 目标版本格式不正确或未设置!");
|
||||
return;
|
||||
}
|
||||
// 验证 manifestTargetVersion 格式
|
||||
if (!manifestTargetVersion || typeof manifestTargetVersion !== 'string') {
|
||||
console.log("[NapCat] [CheckVersion] manifest目标版本格式不正确或未设置!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 写入脚本文件的统一函数
|
||||
const writeScriptToFile = (content) => {
|
||||
@ -21,7 +32,7 @@ try {
|
||||
console.log("[NapCat] [CheckVersion] checkVersion.sh 文件已更新。");
|
||||
};
|
||||
|
||||
if (currentVersion === targetVersion) {
|
||||
if (currentVersion === targetVersion && manifestCurrentVersion === manifestTargetVersion) {
|
||||
// 不需要更新版本,写入一个简单的脚本
|
||||
const simpleScript = "#!/bin/bash\necho \"CheckVersion Is Done\"";
|
||||
writeScriptToFile(simpleScript);
|
||||
@ -32,6 +43,9 @@ try {
|
||||
git config --global user.email "bot@test.wumiao.wang"
|
||||
git config --global user.name "Version"
|
||||
sed -i "s/\\\"version\\\": \\\"${currentVersion}\\\"/\\\"version\\\": \\\"${targetVersion}\\\"/g" package.json
|
||||
sed -i "s/\\\"version\\\": \\\"${manifestCurrentVersion}\\\"/\\\"version\\\": \\\"${manifestTargetVersion}\\\"/g" manifest.json
|
||||
sed -i "s/napCatVersion = '\\${currentVersion}'/napCatVersion = '\\${targetVersion}'/g" ./src/common/version.ts
|
||||
sed -i 's/SettingButton("V[0-9]\+\.[0-9]\+\.[0-9]\+", "napcat-update-button", "secondary")/SettingButton("'"${NEW_VERSION}"'", "napcat-update-button", "secondary")/g' ./static/assets/renderer.js
|
||||
git add .
|
||||
git commit -m "chore:version change"
|
||||
git push -u origin main`;
|
||||
|
Loading…
Reference in New Issue
Block a user