@@ -32,6 +32,7 @@ import {
3232 UpdateMetrics ,
3333} from "../script/types" ;
3434import {
35+ buildAppVersion ,
3536 getBundleSourceMapOutput ,
3637 getMinifyParams ,
3738 getReactNativePackagePath ,
@@ -922,10 +923,7 @@ function getReactNativeProjectAppVersion(command: cli.IReleaseReactCommand, proj
922923
923924 if ( parsedPlist && parsedPlist . CFBundleShortVersionString ) {
924925 if ( isValidVersion ( parsedPlist . CFBundleShortVersionString ) ) {
925- let appVersion : string = parsedPlist . CFBundleShortVersionString ;
926- if ( parsedPlist . CFBundleVersion ) {
927- appVersion = `${ appVersion } -${ parsedPlist . CFBundleVersion } ` ;
928- }
926+ const appVersion : string = buildAppVersion ( parsedPlist . CFBundleShortVersionString , parsedPlist . CFBundleVersion ) ;
929927 log ( `Using the target binary version value "${ appVersion } " from "${ resolvedPlistFile } ".\n` ) ;
930928 return Q ( appVersion ) ;
931929 } else {
@@ -960,7 +958,7 @@ function getReactNativeProjectAppVersion(command: cli.IReleaseReactCommand, proj
960958 } )
961959 . then ( ( buildGradle : any ) => {
962960 let versionName : string = null ;
963- let versionCode : string = null ;
961+ let versionCode : number | null = null ;
964962
965963 // First 'if' statement was implemented as workaround for case
966964 // when 'build.gradle' file contains several 'android' nodes.
@@ -995,9 +993,7 @@ function getReactNativeProjectAppVersion(command: cli.IReleaseReactCommand, proj
995993 if ( isValidVersion ( appVersion ) ) {
996994 // The versionName property is a valid semver string,
997995 // so we can safely use that and move on.
998- if ( versionCode ) {
999- appVersion = `${ appVersion } -${ versionCode } ` ;
1000- }
996+ appVersion = buildAppVersion ( appVersion , versionCode ) ;
1001997 log ( `Using the target binary version value "${ appVersion } " from "${ buildGradlePath } ".\n` ) ;
1002998 return appVersion ;
1003999 } else if ( / ^ \d .* / . test ( appVersion ) ) {
@@ -1044,9 +1040,7 @@ function getReactNativeProjectAppVersion(command: cli.IReleaseReactCommand, proj
10441040 ) ;
10451041 }
10461042
1047- if ( versionCode ) {
1048- appVersion = `${ appVersion } -${ versionCode } ` ;
1049- }
1043+ appVersion = buildAppVersion ( appVersion , versionCode ) ;
10501044 log ( `Using the target binary version value "${ appVersion } " from the "${ propertyName } " key in the "${ propertiesFile } " file.\n` ) ;
10511045 return appVersion . toString ( ) ;
10521046 } ) ;
@@ -1120,7 +1114,7 @@ function getAppVersionFromXcodeProject(command: cli.IReleaseReactCommand, projec
11201114 }
11211115
11221116 const currentProjectVersion = xcodeProj . getBuildProperty ( "CURRENT_PROJECT_VERSION" , command . buildConfigurationName , command . xcodeTargetName ) ;
1123- const appVersion = currentProjectVersion ? ` ${ marketingVersion } - ${ currentProjectVersion } ` : marketingVersion ;
1117+ const appVersion = buildAppVersion ( marketingVersion , currentProjectVersion ) ;
11241118
11251119 console . log ( `Using the target binary version value "${ appVersion } " from "${ resolvedPbxprojFile } ".\n` ) ;
11261120
@@ -1659,9 +1653,7 @@ export const releaseNative = (command: cli.IReleaseNativeCommand): Promise<void>
16591653 await extractIPA ( targetBinaryPath , extractFolder ) ;
16601654 const metadataZip = await extractMetadataFromIOS ( extractFolder , outputFolder ) ;
16611655 const buildVersion = await getIosVersion ( extractFolder ) ;
1662- const iosAppStoreVersion = buildVersion ?. build
1663- ? `${ buildVersion . version } -${ buildVersion . build } `
1664- : buildVersion ?. version ;
1656+ const iosAppStoreVersion = buildAppVersion ( buildVersion . version , buildVersion . build ) ;
16651657 releaseCommandPartial = { package : metadataZip , appStoreVersion : iosAppStoreVersion } ;
16661658 } else {
16671659 if ( targetBinaryPathNormalised . endsWith ( ".apk" ) ) {
@@ -1670,14 +1662,14 @@ export const releaseNative = (command: cli.IReleaseNativeCommand): Promise<void>
16701662
16711663 const reader = await ApkReader . open ( targetBinaryPath ) ;
16721664 const { versionName, versionCode } = await reader . readManifest ( ) ;
1673- const apkAppStoreVersion = versionCode ? ` ${ versionName } - ${ versionCode } ` : versionName ;
1665+ const apkAppStoreVersion = buildAppVersion ( versionName , versionCode ) ;
16741666 const metadataZip = await extractMetadataFromAndroid ( extractFolder , outputFolder ) ;
16751667 releaseCommandPartial = { package : metadataZip , appStoreVersion : apkAppStoreVersion } ;
16761668 } else if ( targetBinaryPathNormalised . endsWith ( ".aab" ) ) {
16771669 log ( chalk . cyan ( `\nExtracting AAB file:\n` ) ) ;
16781670 await extractAAB ( targetBinaryPath , extractFolder ) ;
16791671 const { versionName, versionCode } = await aabParser . parseAabManifest ( targetBinaryPath ) ;
1680- const aabAppStoreVersion = versionCode ? ` ${ versionName } - ${ versionCode } ` : versionName ;
1672+ const aabAppStoreVersion = buildAppVersion ( versionName , versionCode ) ;
16811673
16821674 const metadataZip = await extractMetadataFromAndroid ( `${ extractFolder } /base` , outputFolder ) ; // base folder is nested in AAB
16831675 releaseCommandPartial = { package : metadataZip , appStoreVersion : aabAppStoreVersion } ;
0 commit comments