@@ -396,17 +396,33 @@ func getTargetVersion(allowMajor bool) (*version.Release, string, error) {
396396 if ! allowMajor {
397397 // Get current version info to determine what major version to stay within
398398 info := version .GetBuildInfo ()
399- currentMajor := strings .Split (strings .TrimPrefix (info .Version , "v" ), "." )[0 ]
399+ currentVersion := strings .TrimPrefix (info .Version , "v" )
400+ currentMajor := strings .Split (currentVersion , "." )[0 ]
400401
401402 // If the latest version is in the same major version, use it
402403 if strings .HasPrefix (latestVersion , currentMajor + "." ) {
403404 return release , latestVersion , nil
404405 }
405406
406- // Otherwise, we need to find the latest version within the current major version
407- // For now, return the current version (no upgrade available within major version)
408- // In a full implementation, you'd query all releases and find the latest within the major version
409- return release , info .Version , nil
407+ // Otherwise, find the latest version within the current major version
408+ // Query all releases to find the latest patch/minor within current major
409+ allReleases , err := version .GetAllReleases ()
410+ if err != nil {
411+ // Fallback: return current version if we can't get all releases
412+ return release , currentVersion , nil
413+ }
414+
415+ latestInMajor := currentVersion
416+ for _ , r := range allReleases {
417+ releaseVersion := strings .TrimPrefix (r .TagName , "v" )
418+ if strings .HasPrefix (releaseVersion , currentMajor + "." ) {
419+ if version .CompareVersions (releaseVersion , latestInMajor ) > 0 {
420+ latestInMajor = releaseVersion
421+ }
422+ }
423+ }
424+
425+ return release , latestInMajor , nil
410426 }
411427
412428 return release , latestVersion , nil
0 commit comments