@@ -385,8 +385,15 @@ func (r *releaseCommand) autoversionFile(ctx context.Context, file, channel, ver
385
385
// Utilize the index where the match was found to replace the correct part. The only
386
386
// match group is the version.
387
387
if match := matchRe .FindStringSubmatchIndex (line );match != nil {
388
- logger .Info (ctx ,"updating version number" ,"line_number" ,i + 1 ,"match" ,match ,"old_version" ,line [match [2 ]:match [3 ]])
389
- lines [i ]= line [:match [2 ]]+ version + line [match [3 ]:]
388
+ vg := matchRe .SubexpIndex ("version" )
389
+ if vg == - 1 {
390
+ logger .Error (ctx ,"version group not found in match" ,"num_subexp" ,"match" ,match ,matchRe .NumSubexp (),"subexp_names" ,matchRe .SubexpNames ())
391
+ return xerrors .Errorf ("bug: version group not found in match" )
392
+ }
393
+ start := match [vg * 2 ]
394
+ end := match [vg * 2 + 1 ]
395
+ logger .Info (ctx ,"updating version number" ,"line_number" ,i + 1 ,"match_start" ,start ,"match_end" ,end ,"old_version" ,line [start :end ])
396
+ lines [i ]= line [:start ]+ version + line [end :]
390
397
matchRe = nil
391
398
break
392
399
}