@@ -6,16 +6,33 @@ import { execSync } from 'child_process';
66const __filename = fileURLToPath ( import . meta. url ) ;
77const __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
3148function 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
7693if ( ! hasMobileCommits ( commits ) ) {
7794 console . log ( 'No mobile commits found, skipping mobile version bump' ) ;
0 commit comments