From fb54ac8e2e335ea0620b77117d64bbde738d660e Mon Sep 17 00:00:00 2001 From: Slinetrac Date: Mon, 3 Nov 2025 19:47:50 +0800 Subject: [PATCH] chore(release): unify version format --- scripts/release-version.mjs | 49 +++++++++++++++++++++++-------------- scripts/updater.mjs | 2 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/scripts/release-version.mjs b/scripts/release-version.mjs index a5da62e9..fb6513c4 100644 --- a/scripts/release-version.mjs +++ b/scripts/release-version.mjs @@ -8,9 +8,9 @@ * - A full semver version (e.g., 1.2.3, v1.2.3, 1.2.3-beta, v1.2.3-rc.1) * - A tag: "alpha", "beta", "rc", "autobuild", "autobuild-latest", or "deploytest" * - "alpha", "beta", "rc": Appends the tag to the current base version (e.g., 1.2.3-beta) - * - "autobuild": Appends a timestamped autobuild tag (e.g., 1.2.3-autobuild.0610.cc39b2.r2) - * - "autobuild-latest": Appends an autobuild tag with latest Tauri commit (e.g., 1.2.3-autobuild.0610.a1b2c3d.r2) - * - "deploytest": Appends a timestamped deploytest tag (e.g., 1.2.3-deploytest.0610.cc39b2.r2) + * - "autobuild": Appends a timestamped autobuild tag (e.g., 1.2.3-autobuild.1022.r2+cc39b2) + * - "autobuild-latest": Appends an autobuild tag with latest Tauri commit (e.g., 1.2.3-autobuild.1022.r2+a1b2c3d) + * - "deploytest": Appends a timestamped deploytest tag (e.g., 1.2.3-deploytest.1022.r2+cc39b2) * * Examples: * pnpm release-version 1.2.3 @@ -161,6 +161,25 @@ function generateChannelSuffix({ return segments.join("."); } +/** + * 为 autobuild 渠道构建版本片段 + * @param {Object} options + * @param {"current"|"tauri"} [options.commitSource="current"] + * @returns {{date: string, run: string, metadata: string}} + */ +function generateAutobuildComponents({ commitSource = "current" } = {}) { + const date = getLocalDatePart(); + const run = getRunIdentifier() ?? `manual${Date.now().toString(36)}`; + const commitHash = + commitSource === "tauri" ? getLatestTauriCommit() : getGitShortCommit(); + + return { + date, + run, + metadata: commitHash || "nogit", + }; +} + /** * 验证版本号格式 * @param {string} version @@ -334,23 +353,17 @@ async function main(versionArg) { const baseVersion = getBaseVersion(currentVersion); if (versionArg.toLowerCase() === "autobuild") { - // 格式: 2.3.0-autobuild.0610.cc39b2.r2 - newVersion = `${baseVersion}-autobuild.${generateChannelSuffix({ - includeCommit: true, - commitSource: "tauri", - })}`; + // 格式: 2.3.0-autobuild.1022.r2+cc39b2 + const parts = generateAutobuildComponents({ commitSource: "tauri" }); + newVersion = `${baseVersion}-autobuild.${parts.date}.${parts.run}+${parts.metadata}`; } else if (versionArg.toLowerCase() === "autobuild-latest") { - // 格式: 2.3.0-autobuild.0610.a1b2c3d.r2 (使用最新 Tauri 提交) - newVersion = `${baseVersion}-autobuild.${generateChannelSuffix({ - includeCommit: true, - commitSource: "tauri", - })}`; + // 格式: 2.3.0-autobuild.1022.r2+a1b2c3d (使用最新 Tauri 提交) + const parts = generateAutobuildComponents({ commitSource: "tauri" }); + newVersion = `${baseVersion}-autobuild.${parts.date}.${parts.run}+${parts.metadata}`; } else if (versionArg.toLowerCase() === "deploytest") { - // 格式: 2.3.0-deploytest.0610.cc39b2.r2 - newVersion = `${baseVersion}-deploytest.${generateChannelSuffix({ - includeCommit: true, - commitSource: "tauri", - })}`; + // 格式: 2.3.0-deploytest.1022.r2+cc39b2 + const parts = generateAutobuildComponents({ commitSource: "tauri" }); + newVersion = `${baseVersion}-deploytest.${parts.date}.${parts.run}+${parts.metadata}`; } else { newVersion = `${baseVersion}-${versionArg.toLowerCase()}`; } diff --git a/scripts/updater.mjs b/scripts/updater.mjs index 7b08c4e0..4563b530 100644 --- a/scripts/updater.mjs +++ b/scripts/updater.mjs @@ -200,7 +200,7 @@ async function processRelease(github, options, channelConfig) { const updateData = { version: resolvedVersion, - name: releaseTagName, + tag_name: releaseTagName, notes: await resolveUpdateLog(releaseTagName).catch(() => resolveUpdateLogDefault().catch(() => "No changelog available"), ),