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

[ENG-9] [eas-cli] implement automatic version bumping for ios builds #231

Merged
merged 5 commits into from
Feb 12, 2021

Conversation

dsokal
Copy link
Contributor

@dsokal dsokal commented Feb 10, 2021

Why

https://linear.app/expo/issue/ENG-9/automatic-version-bumping

For iOS builds, we want to automatically bump CFBundleShortVersionString or CFBundleVersion for every build. This lets users run fewer redundant builds. Usually, users forget to bump the version on their own. They find out that they forgot to bump the version after the build completes and .ipa cannot be uploaded to App Store.

How

  • I added a new configuration field in iOS build profiles - autoIncrement. Possible values:
    • true - the same as "buildNumber"
    • false - default, does not bump any version
    • "version" - bumps CFBundleShortVersionString
    • "buildNumber" - bumps CFBundleVersion
  • Versions are bumped on the client side.
    • For generic projects, both app.json and Info.plist are updated.
    • For managed projects, app.json is updated.
  • EAS CLI assumes the following format of versions:
    • CFBundleShortVersionString is a semver. A new version is created by bumping the patch version. E.g. 1.0.0 -> 1.0.1
    • CFBundleVersion is a semver-like string (e.g. 1, 1.2, 1.2.3, 1.2.3.4, and so on). A new version is created by adding 1 to the last component of the string. E.g. 1.2.3.29 -> 1.2.3.30
  • If EAS CLI detects another format of versions, the user is prompted to specify the next version.
  • Currently, there is no support for app.config.js. eas build fails if the project is configured with it and autoIncrement != false.

Test Plan

  • Unit tests
  • Manual tests
    • Generic project
    • Managed project

@dsokal dsokal force-pushed the @dsokal/automatic-version-bumping branch from c9cce85 to b05a134 Compare February 10, 2021 13:44
@github-actions
Copy link

github-actions bot commented Feb 11, 2021

Size Change: +103 kB (0%)

Total Size: 35.9 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 35.9 MB +103 kB (0%)

compressed-size-action

@dsokal dsokal force-pushed the @dsokal/automatic-version-bumping branch 2 times, most recently from 1935369 to 153c30c Compare February 11, 2021 12:50
@dsokal dsokal changed the title [wip] automatic version bumping [eas-cli] implement automatic version bumping for ios builds Feb 11, 2021
@dsokal dsokal changed the title [eas-cli] implement automatic version bumping for ios builds [ENG-9] [eas-cli] implement automatic version bumping for ios builds Feb 11, 2021
@dsokal dsokal marked this pull request as ready for review February 11, 2021 13:41
@dsokal dsokal force-pushed the @dsokal/automatic-version-bumping branch from 153c30c to 611365c Compare February 11, 2021 14:15
@brentvatne
Copy link
Member

let's call the field autoIncrement instead of autoincrement - since they are two separate words (sometimes joined with a dash) we should use camel casing

// Currently we are only updaing runtime version durring build, but if it changes in a future
// this message should also contain more info on that (or be more generic)
await reviewAndCommitChangesAsync(`Update runtime version in the ${projectType} project`, {
await reviewAndCommitChangesAsync(`[EAS Build] Configure project`, {
Copy link
Contributor

Choose a reason for hiding this comment

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

For build:configure we have

  [RequestedPlatform.Android]: 'Configure EAS Build for Android',
  [RequestedPlatform.iOS]: 'Configure EAS Build for iOS',
  [RequestedPlatform.All]: 'Configure EAS Build',

This commit should clearly state that this is commit that happens before build and not build:configure

}
} else {
const buildNumber = IOSConfig.Version.getBuildNumber(exp);
if (buildNumber.match(/^\d+$/)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I remember correctly we discussed that in the case of build number we require the last segment to be a number but except that we should support all formats allowed for this value.

});

const iOSManagedSchema = Joi.object({
workflow: Joi.string().valid('managed').required(),
credentialsSource: Joi.string().valid('local', 'remote', 'auto').default('auto'),
releaseChannel: Joi.string(),
distribution: Joi.string().valid('store', 'internal').default('store'),
autoIncrement: Joi.alternatives()
.try(Joi.boolean(), Joi.string().valid('version', 'buildNumber'))
.default('buildNumber'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.default('buildNumber'),
.default(false),

modifyConfig: (config: any) => void
): Promise<void> {
const paths = ExpoConfig.getConfigFilePaths(projectDir);
assert(paths.staticConfigPath, "can't update dynamic configs");
Copy link
Contributor

@wkozyra95 wkozyra95 Feb 12, 2021

Choose a reason for hiding this comment

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

Make sure that this condition is handled earlier with proper error message sth along the lines autoIncrement options is not supported with dynamic config

(optional) when you check that you could also verify if the version in config is the same as in static config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

await writePlistAsync(infoPlistPath, infoPlist);
}

function ensureDynamicConfigDoesNotExist(projectDir: string): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function ensureDynamicConfigDoesNotExist(projectDir: string): void {
function ensureStaticConfigDoesExist(projectDir: string): void {

@dsokal dsokal merged commit 1ac0af5 into main Feb 12, 2021
@dsokal dsokal deleted the @dsokal/automatic-version-bumping branch February 12, 2021 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants