also looking at this
fix: synchronize drifted native versions in recursive releases
#2015
2 files
+26
-2
| @@ -413,8 +413,11 @@ export function updateVersionInFile(filePath: string, oldVersion: string, newVer | ||
| 413 | 413 | if (isZigZon) { |
| 414 | 414 | // Handle Zig build.zig.zon files |
| 415 | 415 | // Format: .version = "0.0.0", |
| 416 | const declaredVersion = forceUpdate | |
| 417 | ? content.match(/\.version\s*=\s*"([^"]+)"/)?.[1] ?? oldVersion | |
| 418 | : oldVersion | |
| 416 | 419 | const versionRegex = new RegExp( |
| 417 | `(\\.version\\s*=\\s*")${oldVersion.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}("\\s*,)`, | |
| 420 | `(\\.version\\s*=\\s*")${declaredVersion.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}("\\s*,)`, | |
| 418 | 421 | 'g', |
| 419 | 422 | ) |
| 420 | 423 | if (content.match(versionRegex) || forceUpdate) { |
| @@ -433,6 +436,7 @@ export function updateVersionInFile(filePath: string, oldVersion: string, newVer | ||
| 433 | 436 | } |
| 434 | 437 | |
| 435 | 438 | const packageJson = JSON.parse(jsonContent) |
| 439 | const declaredVersion = forceUpdate ? String(packageJson.version) : oldVersion | |
| 436 | 440 | if (packageJson.version === oldVersion || forceUpdate) { |
| 437 | 441 | packageJson.version = newVersion |
| 438 | 442 | |
| @@ -440,7 +444,7 @@ export function updateVersionInFile(filePath: string, oldVersion: string, newVer | ||
| 440 | 444 | if (isJsonc) { |
| 441 | 445 | // Replace the version value while preserving comments and formatting |
| 442 | 446 | const versionRegex = new RegExp( |
| 443 | `(["']version["']\\s*:\\s*)["']${oldVersion.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}["']`, | |
| 447 | `(["']version["']\\s*:\\s*)["']${declaredVersion.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}["']`, | |
| 444 | 448 | 'g', |
| 445 | 449 | ) |
| 446 | 450 | newContent = content.replace(versionRegex, `$1"${newVersion}"`) |