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

Make iOS update commands run in sequence instead of all at once #2024

Merged
merged 4 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/actions/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,17 @@ exports.updateiOSVersion = function updateiOSVersion(version) {
console.log('Updating iOS', `CFBundleShortVersionString: ${shortVersion}`, `CFBundleVersion: ${cfVersion}`);

// Pass back the cfVersion in the return array so we can set the NEW_IOS_VERSION in ios.yml
return Promise.all([
cfVersion,
const updatePromise = [
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH_TEST}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH_TEST}`),
]
.reduce((previousPromise, currentPromise) => previousPromise.then(() => currentPromise()), Promise.resolve());
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! This is sure ugly code 🧌 It would be cool to make this into a utility at some point that we can use whenever we need it. Seems like it should work well for you in this case!

Copy link
Contributor

Choose a reason for hiding this comment

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

Another possible cure for this would be to use execSync(): https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options so that they run synchronously.

Copy link
Contributor

@tgolen tgolen Mar 23, 2021

Choose a reason for hiding this comment

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

Oh, and also... I think exec() in the array is already starting all the promises all at once. The code you added just makes sure that they are resolved one at a time... So to really get what you want, I think you need to do something more like this:

const updateCommands = [
    `/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH}`,
    `/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH_TEST}`,
    `/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH}`,
    `/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH_TEST}`
]
.reduce((previousPromise, command) => previousPromise.then(() => exec(command)), Promise.resolve());;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh yeah execSync seems like a much better choice for my use case! Thanks!


return Promise.all([
cfVersion,
updatePromise,
]);
};

Expand Down
9 changes: 7 additions & 2 deletions .github/libs/nativeVersionUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ exports.updateiOSVersion = function updateiOSVersion(version) {
console.log('Updating iOS', `CFBundleShortVersionString: ${shortVersion}`, `CFBundleVersion: ${cfVersion}`);

// Pass back the cfVersion in the return array so we can set the NEW_IOS_VERSION in ios.yml
return Promise.all([
cfVersion,
const updatePromise = [
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${shortVersion}" ${PLIST_PATH_TEST}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH}`),
exec(`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${cfVersion}" ${PLIST_PATH_TEST}`),
]
.reduce((previousPromise, currentPromise) => previousPromise.then(() => currentPromise()), Promise.resolve());

return Promise.all([
cfVersion,
updatePromise,
]);
};