Skip to content

Commit ef6b9f6

Browse files
bealqiuclaude
andcommitted
fix: 同步版本号至 1.0.12 并添加版本一致性校验
- 更新 package.json 和 tauri.conf.json 版本至 1.0.12 - 新增 scripts/bump-version.js 版本管理脚本 - CI release workflow 打包前校验版本一致性 使用方式: node scripts/bump-version.js 1.0.13 # 设置版本 node scripts/bump-version.js --check # 仅检查一致性 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 60ef083 commit ef6b9f6

4 files changed

Lines changed: 102 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ jobs:
6262
- name: Install frontend dependencies
6363
run: pnpm install
6464

65+
- name: Verify version consistency
66+
run: node scripts/bump-version.js --check
67+
6568
- name: Build Tauri app
6669
uses: tauri-apps/tauri-action@v0
6770
env:

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "app",
33
"private": true,
4-
"version": "1.0.8",
4+
"version": "1.0.12",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

packages/app/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "ReadAny",
4-
"version": "1.0.8",
4+
"version": "1.0.12",
55
"identifier": "com.readany.app",
66
"build": {
77
"beforeDevCommand": "pnpm dev",

scripts/bump-version.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env node
2+
/**
3+
* scripts/bump-version.js
4+
*
5+
* Usage:
6+
* node scripts/bump-version.js 1.0.12 # Set version
7+
* node scripts/bump-version.js --check # Check consistency only
8+
*
9+
* Syncs version across:
10+
* - packages/app/package.json
11+
* - packages/app/src-tauri/tauri.conf.json
12+
*/
13+
const fs = require("fs");
14+
const path = require("path");
15+
16+
const ROOT = path.resolve(__dirname, "..");
17+
18+
const VERSION_FILES = [
19+
{
20+
path: "packages/app/package.json",
21+
read: (content) => JSON.parse(content).version,
22+
write: (content, version) => {
23+
const json = JSON.parse(content);
24+
json.version = version;
25+
return JSON.stringify(json, null, 2) + "\n";
26+
},
27+
},
28+
{
29+
path: "packages/app/src-tauri/tauri.conf.json",
30+
read: (content) => JSON.parse(content).version,
31+
write: (content, version) => {
32+
const json = JSON.parse(content);
33+
json.version = version;
34+
return JSON.stringify(json, null, 2) + "\n";
35+
},
36+
},
37+
];
38+
39+
function readVersions() {
40+
return VERSION_FILES.map((f) => {
41+
const fullPath = path.join(ROOT, f.path);
42+
const content = fs.readFileSync(fullPath, "utf8");
43+
return { file: f.path, version: f.read(content) };
44+
});
45+
}
46+
47+
function checkConsistency() {
48+
const versions = readVersions();
49+
const unique = [...new Set(versions.map((v) => v.version))];
50+
51+
console.log("Version check:");
52+
for (const v of versions) {
53+
console.log(` ${v.file}: ${v.version}`);
54+
}
55+
56+
if (unique.length !== 1) {
57+
console.error("\nERROR: Version mismatch detected!");
58+
process.exit(1);
59+
}
60+
61+
console.log(`\nAll versions consistent: ${unique[0]}`);
62+
return unique[0];
63+
}
64+
65+
function setVersion(newVersion) {
66+
if (!/^\d+\.\d+\.\d+$/.test(newVersion)) {
67+
console.error(`Invalid version format: ${newVersion} (expected x.y.z)`);
68+
process.exit(1);
69+
}
70+
71+
for (const f of VERSION_FILES) {
72+
const fullPath = path.join(ROOT, f.path);
73+
const content = fs.readFileSync(fullPath, "utf8");
74+
const updated = f.write(content, newVersion);
75+
fs.writeFileSync(fullPath, updated, "utf8");
76+
console.log(` Updated ${f.path} -> ${newVersion}`);
77+
}
78+
79+
console.log(`\nVersion bumped to ${newVersion}`);
80+
}
81+
82+
// Main
83+
const arg = process.argv[2];
84+
85+
if (!arg) {
86+
console.log("Usage:");
87+
console.log(" node scripts/bump-version.js <version> # Set version");
88+
console.log(" node scripts/bump-version.js --check # Check consistency");
89+
process.exit(0);
90+
}
91+
92+
if (arg === "--check") {
93+
checkConsistency();
94+
} else {
95+
setVersion(arg);
96+
checkConsistency();
97+
}

0 commit comments

Comments
 (0)