Skip to content

Commit 20e3d2c

Browse files
authored
Merge pull request #2229 from oasisprotocol/mz/mobileBuildVersion
Update internal mobile build versions
2 parents 98c69fc + f5a50e9 commit 20e3d2c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.changelog/2229.internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update internal mobile build versions

internals/scripts/changelog.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,30 @@ prettier
5353

5454
execSync(`towncrier build --version ${version}`, { stdio: 'inherit' })
5555

56+
// Mobile build version used internally in stores
57+
const gitCommitCount = execSync('git rev-list --count HEAD', { encoding: 'utf8' }).trim()
58+
const versionPrefix = version
59+
.split('.')
60+
.map((n, i) => (i > 0 ? n.padStart(3, '0') : n))
61+
.join('')
62+
const newVersionCode = `${versionPrefix}${gitCommitCount}`
63+
5664
// Android app needs to bump versionName in build.gradle
5765
const gradleFilePath = './android/app/build.gradle'
5866
const gradleContent = fs.readFileSync(gradleFilePath, 'utf8')
59-
const updatedGradleContent = gradleContent.replace(/versionName\s+"[\d.]+"/, `versionName "${version}"`)
67+
let updatedGradleContent = gradleContent.replace(/versionName\s+"[\d.]+"/, `versionName "${version}"`)
68+
updatedGradleContent = updatedGradleContent.replace(/versionCode\s+\d+/, `versionCode ${newVersionCode}`)
6069
fs.writeFileSync(gradleFilePath, updatedGradleContent, 'utf8')
6170

6271
// iOS app needs to bump MARKETING_VERSION in project.pbxproj
6372
const pbxprojFilePath = './ios/App/App.xcodeproj/project.pbxproj'
6473
const pbxprojContent = fs.readFileSync(pbxprojFilePath, 'utf8')
65-
const updatedPbxprojContent = pbxprojContent.replace(
74+
let updatedPbxprojContent = pbxprojContent.replace(
6675
/MARKETING_VERSION = [\d.]+;/g,
6776
`MARKETING_VERSION = ${version};`,
6877
)
78+
updatedPbxprojContent = updatedPbxprojContent.replace(
79+
/CURRENT_PROJECT_VERSION = \d+;/g,
80+
`CURRENT_PROJECT_VERSION = ${newVersionCode};`,
81+
)
6982
fs.writeFileSync(pbxprojFilePath, updatedPbxprojContent, 'utf8')

0 commit comments

Comments
 (0)