moyf_easy-copy/scripts/release-tag.mjs
2025-05-09 20:01:47 +08:00

37 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 执行发版和打标签操作的专用脚本
*/
import { execSync } from "child_process";
// 从 package.json 获取当前版本号
const version = process.env.npm_package_version;
console.log(`📦 Preparing to release version: ${version}`);
try {
// 执行 git add 操作
console.log("📝 添加文件到 git...");
execSync("git add .", { stdio: "inherit" });
// 执行 git commit 操作
console.log("💾 创建提交...");
execSync(`git commit -m "build: ${version}"`, { stdio: "inherit" });
// 执行 git push 操作
console.log("🚀 推送到远程...");
execSync("git push", { stdio: "inherit" });
// 创建版本标签
console.log(`🏷️ 创建标签: ${version}`);
execSync(`git tag ${version}`, { stdio: "inherit" });
// 推送标签到远程
console.log("📤 推送标签到远程...");
execSync("git push --tags", { stdio: "inherit" });
console.log(`✅ 成功发布版本 ${version}!`);
console.log(`🔗 点击跳转发布页https://github.com/Moyf/easy-copy/releases`)
} catch (error) {
console.error(`❌ 发布失败: ${error.message}`);
process.exit(1);
}