Skip to content

Commit ab946fc

Browse files
authored
Merge pull request #987 from web3dev1337/fix/macos-app-version-check
fix(ci): macOS app bundle version check reads Info.plist
2 parents 8c514b6 + fa99126 commit ab946fc

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

scripts/release/verify-bundle-version.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ function listBundleFiles(bundleTypeDir, extensions) {
9999
.map((entry) => path.join(bundleTypeDir, entry));
100100
}
101101

102+
function readMacOSAppBundleVersion(appPath) {
103+
const plistPath = path.join(appPath, 'Contents', 'Info.plist');
104+
try {
105+
const content = fs.readFileSync(plistPath, 'utf8');
106+
const match = content.match(/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/);
107+
return match ? match[1].trim() : null;
108+
} catch {
109+
return null;
110+
}
111+
}
112+
102113
function verifyBundleVersion({ targetDir, profile, expectedVersion, platform, bundles }) {
103114
const normalizedPlatform = normalizePlatform(platform);
104115
const bundleTypes = resolveBundleTypes({ bundles, platform: normalizedPlatform });
@@ -135,6 +146,22 @@ function verifyBundleVersion({ targetDir, profile, expectedVersion, platform, bu
135146
continue;
136147
}
137148

149+
// macOS .app bundles don't include version in filename — check Info.plist
150+
if (bundleType === 'app') {
151+
for (const filePath of files) {
152+
const plistVersion = readMacOSAppBundleVersion(filePath);
153+
if (plistVersion && plistVersion === expectedVersion) {
154+
continue;
155+
}
156+
if (!plistVersion) {
157+
errors.push(`Could not read version from ${path.basename(filePath)}/Contents/Info.plist`);
158+
} else if (plistVersion !== expectedVersion) {
159+
errors.push(`${path.basename(filePath)} has version ${plistVersion}, expected ${expectedVersion}`);
160+
}
161+
}
162+
continue;
163+
}
164+
138165
const matchedFiles = files.filter((filePath) => path.basename(filePath).includes(expectedVersion));
139166
const staleFiles = files.filter((filePath) => !path.basename(filePath).includes(expectedVersion));
140167

0 commit comments

Comments
 (0)