Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Ensure bundle version strings are compatible before auto-merging CP PR #6199

Merged
merged 12 commits into from
Nov 17, 2021
8 changes: 8 additions & 0 deletions .github/actions/checkBundleVersionStringMatch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'Check if Bundle Versions Match'
description: "Check if the CFBundleVersion string is compatible with the CFBundleShortVersionString"
outputs:
BUNDLE_VERSIONS_MATCH:
description: Whether or not the bundle versions match
runs:
using: 'node12'
main: './index.js'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const core = require('@actions/core');
const {execSync} = require('child_process');
const {PLIST_PATH} = require('../../libs/nativeVersionUpdater');

const bundleVersion = execSync(`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" ${PLIST_PATH}`);
const shortBundleVersion = execSync(`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" ${PLIST_PATH}`);

console.log(`Bundle Version: ${bundleVersion}`);
console.log(`Short Bundle Version: ${shortBundleVersion}`);
if (shortBundleVersion !== (bundleVersion.split('-') || [''])[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: This comment is more for me to learn. I see in nativeVersionUpdater.js that the shortBundleVersion is obtained as following:

const shortVersion = version.split('-')[0];

That means in terms of your example from the PR body: 1-1-1-0 this would be 1 and then on the next line we add another zero to the version:

const cfVersion = version.includes('-') ? version.replace('-', '.') : `${version}.0`;

What I do not understand is taking the first - [0] element of the split would not check for the case you have described in the PR body:

  • Compatible bundle version strings: 1.1.1 and 1.1.1.0
  • Incompatible bundle version strings: 1.1.1 and 1.1.0.0

Thank you for explanation of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no worries! So in this case we're grabbing the version number from the info.plist, which has the versions formatted as x.x.x-x. So if the bundleVersion is 1.1.1-0 and the shortBundleVersion is 1.1.1, then they would match. Let me know if that makes sense!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahaa! That makes a lot of sense, did not catch that, thank you!

console.log('Bundle Versions do not match');
core.setOutput('BUNDLE_VERSIONS_MATCH', false);
} else {
console.log('Bundle Versions match');
core.setOutput('BUNDLE_VERSIONS_MATCH', true);
}
Loading