Skip to content

Commit 233f6b4

Browse files
committed
fix(mobile): correct version bump calculation to check commits since last bump
1 parent f552220 commit 233f6b4

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

apps/mobile/v1/app.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "Typelets",
44
"slug": "typelets",
5-
"version": "1.7.0",
5+
"version": "1.0.0",
66
"orientation": "default",
77
"icon": "./assets/images/icon.png",
88
"scheme": "typelets",
@@ -28,7 +28,7 @@
2828
],
2929
"ios": {
3030
"bundleIdentifier": "com.typelets.notes",
31-
"buildNumber": "9",
31+
"buildNumber": "1",
3232
"supportsTablet": true,
3333
"infoPlist": {
3434
"NSCameraUsageDescription": "This app uses the camera to capture photos for your notes.",
@@ -38,7 +38,7 @@
3838
},
3939
"android": {
4040
"package": "com.typelets.notes",
41-
"versionCode": 9,
41+
"versionCode": 1,
4242
"softwareKeyboardLayoutMode": "resize",
4343
"adaptiveIcon": {
4444
"backgroundColor": "#FFFFFF",

apps/mobile/v1/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "v1",
33
"main": "expo-router/entry",
4-
"version": "1.7.0",
4+
"version": "1.0.0",
55
"scripts": {
66
"start": "expo start",
77
"reset-project": "node ./scripts/reset-project.js",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const APP_VERSION = '1.7.0';
1+
export const APP_VERSION = '1.0.0';

scripts/update-mobile-version.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,33 @@ import { execSync } from 'child_process';
66
const __filename = fileURLToPath(import.meta.url);
77
const __dirname = path.dirname(__filename);
88

9-
// Get commits since last release
10-
function getCommitsSinceLastRelease() {
9+
// Get commits since last mobile version bump
10+
function getCommitsSinceLastMobileBump() {
1111
try {
12-
const commits = execSync('git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s"', { encoding: 'utf8' });
13-
return commits.split('\n').filter(Boolean);
12+
// Find the last commit that changed mobile package.json version
13+
// This is typically a "chore(mobile): bump mobile app version" commit
14+
const lastBumpCommit = execSync(
15+
'git log -1 --format=%H --grep="chore(mobile): bump mobile app version" -- apps/mobile/v1/package.json',
16+
{ encoding: 'utf8' }
17+
).trim();
18+
19+
if (lastBumpCommit) {
20+
// Get commits since that bump commit
21+
const commits = execSync(
22+
`git log ${lastBumpCommit}..HEAD --pretty=format:"%s"`,
23+
{ encoding: 'utf8' }
24+
);
25+
return commits.split('\n').filter(Boolean);
26+
}
27+
28+
// If no bump commit found, just get the last commit
29+
const lastCommit = execSync('git log -1 --pretty=format:"%s"', { encoding: 'utf8' });
30+
return lastCommit ? [lastCommit] : [];
1431
} catch (error) {
15-
// If no previous tag exists, get all commits
32+
// Fallback to last commit
1633
try {
17-
const commits = execSync('git log --pretty=format:"%s"', { encoding: 'utf8' });
18-
return commits.split('\n').filter(Boolean);
34+
const lastCommit = execSync('git log -1 --pretty=format:"%s"', { encoding: 'utf8' });
35+
return lastCommit ? [lastCommit] : [];
1936
} catch {
2037
return [];
2138
}
@@ -27,21 +44,21 @@ function hasMobileCommits(commits) {
2744
return commits.some(commit => commit.includes('(mobile)'));
2845
}
2946

30-
// Determine version bump type for mobile
47+
// Determine version bump type for mobile based on the HIGHEST priority commit
3148
function getMobileVersionBump(commits) {
3249
const mobileCommits = commits.filter(commit => commit.includes('(mobile)'));
3350

34-
// Check for breaking changes
51+
// Check for breaking changes (highest priority)
3552
if (mobileCommits.some(commit => commit.includes('BREAKING CHANGE') || commit.startsWith('feat(mobile)!'))) {
3653
return 'major';
3754
}
3855

39-
// Check for features
56+
// Check for features (medium priority)
4057
if (mobileCommits.some(commit => commit.startsWith('feat(mobile)'))) {
4158
return 'minor';
4259
}
4360

44-
// Check for fixes
61+
// Check for fixes (low priority)
4562
if (mobileCommits.some(commit => commit.startsWith('fix(mobile)'))) {
4663
return 'patch';
4764
}
@@ -71,7 +88,7 @@ function bumpVersion(version, type) {
7188
}
7289

7390
// Main execution
74-
const commits = getCommitsSinceLastRelease();
91+
const commits = getCommitsSinceLastMobileBump();
7592

7693
if (!hasMobileCommits(commits)) {
7794
console.log('No mobile commits found, skipping mobile version bump');

0 commit comments

Comments
 (0)