@@ -86,28 +86,28 @@ def __str__(self):
86
86
class ScriptState :
87
87
88
88
def __init__ (self ):
89
- self .current_ser_ver_id = None
90
- self .new_ser_ver_id = None
89
+ self .latest_ser_ver_id = None
90
+ self .next_ser_ver_id = None
91
91
self .major_version = None
92
- self .current_version = None
93
- self .new_version = None
92
+ self .latest_version = None
93
+ self .next_version = None
94
94
self .pr_labels = {}
95
95
self .pr_titles = {}
96
96
self .prs_bump_ser_ver_id = False
97
97
self .gotoStep = False
98
98
self .step = None
99
99
100
- def new_version_tag (self ):
101
- return f'v{ self .new_version } '
100
+ def next_version_tag (self ):
101
+ return f'v{ self .next_version } '
102
102
103
- def curr_version_tag (self ):
104
- return f'v{ self .current_version } '
103
+ def latest_version_tag (self ):
104
+ return f'v{ self .latest_version } '
105
105
106
- def new_version_description (self ):
107
- return f'Version { self .new_version } ({ self .new_ser_ver_id } )'
106
+ def next_version_description (self ):
107
+ return f'Version { self .next_version } ({ self .next_ser_ver_id } )'
108
108
109
- def is_ser_ver_id_new (self ):
110
- return self .new_ser_ver_id != self .current_ser_ver_id
109
+ def is_ser_ver_id_next (self ):
110
+ return self .next_ser_ver_id != self .latest_ser_ver_id
111
111
112
112
def run (self , step ):
113
113
if not self .gotoStep :
@@ -158,7 +158,7 @@ def main():
158
158
set_maven_pom_version ()
159
159
set_ser_ver_id ()
160
160
run_maven_test ()
161
- commit_new_versions ()
161
+ commit_next_versions ()
162
162
tag_release ()
163
163
push_release_branch_and_tag ()
164
164
print_summary ()
@@ -182,9 +182,9 @@ def setup_and_verify():
182
182
verify_release_base_and_release_branch_exist ()
183
183
verify_no_local_git_changes ()
184
184
resolve_version_number ()
185
- resolve_new_version ()
185
+ resolve_next_version ()
186
186
list_labeled_prs ()
187
- resolve_new_ser_ver_id ()
187
+ resolve_next_ser_ver_id ()
188
188
print_setup ()
189
189
190
190
@@ -222,7 +222,7 @@ def merge_in_ext_branches():
222
222
info (f'Config branch merged: { config .release_path (branch )} ' )
223
223
224
224
225
- # Merge the old version into the new version. This only keep a reference to the old version, the
225
+ # Merge the old version into the next version. This only keep a reference to the old version, the
226
226
# resulting git tree of the merge is that of the new branch head, effectively ignoring all changes
227
227
# from the old release. This creates a continuous line of releases in the release branch.
228
228
def merge_in_old_release_with_no_changes ():
@@ -243,41 +243,41 @@ def run_custom_release_extensions():
243
243
244
244
def set_maven_pom_version ():
245
245
section ('Set Maven project version ...' )
246
- execute ('mvn' , 'versions:set' , f'-DnewVersion={ state .new_version } ' ,
246
+ execute ('mvn' , 'versions:set' , f'-DnewVersion={ state .next_version } ' ,
247
247
'-DgenerateBackupPoms=false' , quiet = True )
248
- info (f'New version set: { state .new_version } ' )
248
+ info (f'New version set: { state .next_version } ' )
249
249
250
250
251
251
def set_ser_ver_id ():
252
252
section ('Set serialization.version.id ...' )
253
- new_ser_ver_id_element = f'<{ SER_VER_ID_PROPERTY } >{ state .new_ser_ver_id } </{ SER_VER_ID_PROPERTY } >'
253
+ next_ser_ver_id_element = f'<{ SER_VER_ID_PROPERTY } >{ state .next_ser_ver_id } </{ SER_VER_ID_PROPERTY } >'
254
254
255
255
with open (POM_FILE_NAME , 'r' ) as input_stream :
256
256
pom_file = input_stream .read ()
257
- pom_file = re .sub (SER_VER_ID_PATTERN , new_ser_ver_id_element , pom_file , count = 1 )
257
+ pom_file = re .sub (SER_VER_ID_PATTERN , next_ser_ver_id_element , pom_file , count = 1 )
258
258
with open (POM_FILE_NAME , 'w' ) as output :
259
259
output .write (pom_file )
260
- prefix = 'New' if (state .is_ser_ver_id_new ()) else 'Same'
261
- info (f'{ prefix } serialization.version.id set: { state .new_ser_ver_id } ' )
260
+ prefix = 'New' if (state .is_ser_ver_id_next ()) else 'Same'
261
+ info (f'{ prefix } serialization.version.id set: { state .next_ser_ver_id } ' )
262
262
263
263
264
- def commit_new_versions ():
265
- section ('Commit new version with version and serialization version id set ...' )
264
+ def commit_next_versions ():
265
+ section ('Commit pom.xml with next version and serialization version id set ...' )
266
266
git ('add' , '.' )
267
- git_dr ('commit' , '--all' , '-m' , state .new_version_description ())
268
- info (f'Commit done: { state .new_version_description ()} ' )
267
+ git_dr ('commit' , '--all' , '-m' , state .next_version_description ())
268
+ info (f'Commit done: { state .next_version_description ()} ' )
269
269
270
270
271
271
def tag_release ():
272
- section (f'Tag release with { state .new_version } ...' )
273
- git_im ('tag' , '-a' , state .new_version_tag (), '-m' , state .new_version_description ())
274
- info (f'Tag done: { state .new_version_tag ()} ' )
272
+ section (f'Tag release with { state .next_version } ...' )
273
+ git_im ('tag' , '-a' , state .next_version_tag (), '-m' , state .next_version_description ())
274
+ info (f'Tag done: { state .next_version_tag ()} ' )
275
275
276
276
277
277
def push_release_branch_and_tag ():
278
- section ('Push new release with pom.xml versions and new tag' )
278
+ section ('Push new release with pom.xml changes and new tag' )
279
279
git_dr ('push' , '-f' , f'{ config .release_remote } ' , f'{ config .release_branch } ' )
280
- git_dr ('push' , '-f' , f'{ config .release_remote } ' , f'v{ state .new_version } ' )
280
+ git_dr ('push' , '-f' , f'{ config .release_remote } ' , f'v{ state .next_version } ' )
281
281
info (f'Release pushed to: { config .release_branch_path ()} ' )
282
282
delete_script_state ()
283
283
info ('\n RELEASE SUCCESS!\n ' )
@@ -293,9 +293,9 @@ def print_summary():
293
293
294
294
## Version
295
295
296
- - New version/git tag: `{ state .new_version } `
297
- - New serialization version: `{ state .new_ser_ver_id } `
298
- - Old serialization version: `{ state .current_ser_ver_id } `
296
+ - New version/git tag: `{ state .next_version } `
297
+ - New serialization version: `{ state .next_ser_ver_id } `
298
+ - Old serialization version: `{ state .latest_ser_ver_id } `
299
299
300
300
"""
301
301
with open (SUMMARY_FILE , mode = "w" , encoding = "UTF-8" ) as f :
@@ -307,7 +307,7 @@ def print_summary():
307
307
url = f"https://github.com/opentripplanner/OpenTripPlanner/pull/{ pr } "
308
308
print (f" - { state .pr_titles [pr ]} [#{ pr } ]({ url } ) { state .pr_labels [pr ]} " .replace ("'" , "`" ),
309
309
file = f )
310
- p = execute ("./script/changelog-diff.py" , state .curr_version_tag (), state .new_version_tag ())
310
+ p = execute ("./script/changelog-diff.py" , state .latest_version_tag (), state .next_version_tag ())
311
311
print (p .stdout , file = f )
312
312
313
313
@@ -430,16 +430,16 @@ def resolve_version_number():
430
430
state .major_version = read_major_version_from_pom (version_qualifier , options .release_base ())
431
431
432
432
433
- def resolve_new_version ():
434
- info ('Resolve new version number ...' )
433
+ def resolve_next_version ():
434
+ info ('Resolve next version number ...' )
435
435
p = git ('tag' , '--list' , '--sort=-v:refname' , error_msg = 'Fetch git tags failed!' )
436
436
tags = p .stdout .splitlines ()
437
437
438
438
prefix = f'{ state .major_version } -{ config .release_remote } -'
439
439
pattern = re .compile ('v' + prefix .replace ('.' , r'\.' ) + r'(\d+)' )
440
440
max_tag_version = max ((int (m .group (1 )) for tag in tags if (m := pattern .match (tag ))), default = 0 )
441
- state .current_version = prefix + str (max_tag_version )
442
- state .new_version = prefix + str (1 + max_tag_version )
441
+ state .latest_version = prefix + str (max_tag_version )
442
+ state .next_version = prefix + str (1 + max_tag_version )
443
443
444
444
445
445
def list_labeled_prs ():
@@ -501,36 +501,41 @@ def list_labeled_prs():
501
501
LBL_BUMP_SER_VER_ID in labels for labels in state .pr_labels .values ())
502
502
503
503
504
- def resolve_new_ser_ver_id ():
505
- info ('Resolve the new serialization version id ...' )
506
- curr_release_hash = git_show_ref (git_tag (state .current_version ))
507
- curr_ser_ver_id = read_ser_ver_id_from_pom_file (curr_release_hash )
504
+ # Find out what the next serialization version id should be. First look at the merged pending PRs.
505
+ # If none of the PRs have the 'bump serialization id' label set, then find the upstream
506
+ # serialization-version-id for the release-base and the latest serialization version. If these
507
+ # serialization-version-ids are different, then we need to bump the serialization version id. To
508
+ # find the *upstream* ids we look at the git history/log for serialization ids NOT matching the
509
+ # project serialization version id prefix - this is assumed to be the latest serialization version
510
+ # from the upstream project.
511
+ #
512
+ # If the '--release' option is used then the serialization version id is NOT updated. Use the
513
+ # '--serVerId' option together with the '--release' to force update the serialization version id.
514
+ #
515
+ def resolve_next_ser_ver_id ():
516
+ info ('Resolve the next serialization version id ...' )
517
+ latest_release_hash = git_show_ref (git_tag (state .latest_version ))
518
+ latest_ser_ver_id = read_ser_ver_id_from_pom_file (latest_release_hash )
508
519
bump_ser_ver_id = options .bump_ser_ver_id
509
520
510
- # If none of the PRs have the 'bump serialization id' label set, then find the upstream
511
- # serialization-version-id for the release-base and the current version. If these
512
- # serialization-version-ids are different, then we need to bump the new release serialization
513
- # version id. To find the *upstream* ids we step back in the git history looking for an id
514
- # not matching the project serialization version id prefix - this is assumed to be the latest
515
- # serialization version from the upstream project.
516
- if not bump_ser_ver_id :
517
- info (' - Find upstream serialization version id for current release ...' )
518
- curr_upstream_id = find_upstream_ser_ver_id_in_history (curr_release_hash )
521
+ if not (bump_ser_ver_id or options .releaseOnly ):
522
+ info (' - Find upstream serialization version id for latest release ...' )
523
+ latest_upstream_id = find_upstream_ser_ver_id_in_history (latest_release_hash )
519
524
520
525
info (f' - Find base serialization version id ...' )
521
526
base_hash = git_show_ref (options .release_base ())
522
527
base_upstream_id = find_upstream_ser_ver_id_in_history (base_hash )
523
528
524
529
# Update serialization version id in release if serialization version id has changed
525
- bump_ser_ver_id = curr_upstream_id != base_upstream_id
526
- info (f' - The current upstream serialization.ver.id is { curr_upstream_id } '
530
+ bump_ser_ver_id = latest_upstream_id != base_upstream_id
531
+ info (f' - The latest upstream serialization.ver.id is { latest_upstream_id } '
527
532
f'and the base upstream id is { base_upstream_id } .' )
528
533
529
- state .current_ser_ver_id = curr_ser_ver_id
534
+ state .latest_ser_ver_id = latest_ser_ver_id
530
535
if bump_ser_ver_id :
531
- state .new_ser_ver_id = bump_release_ser_ver_id (curr_ser_ver_id )
536
+ state .next_ser_ver_id = bump_release_ser_ver_id (latest_ser_ver_id )
532
537
else :
533
- state .new_ser_ver_id = curr_ser_ver_id
538
+ state .next_ser_ver_id = latest_ser_ver_id
534
539
535
540
536
541
# Find the serialization-version-id for the upstream git project using the git log starting
@@ -555,7 +560,7 @@ def print_setup():
555
560
- Bump ser.ver.id ............. : { options .bump_ser_ver_id }
556
561
- Dry run .................... : { options .dry_run }
557
562
- Debugging ................... : { options .debugging }
558
- - Release ...................... : { options .releaseOnly }
563
+ - Release ..................... : { options .releaseOnly }
559
564
560
565
Config
561
566
- Upstream git repo remote name : { config .upstream_remote }
@@ -571,10 +576,10 @@ def print_setup():
571
576
info (f'''
572
577
Release info
573
578
- Project major version ....... : { state .major_version }
574
- - Current version ............. : { state .current_version }
575
- - New version ................. : { state .new_version }
576
- - Current ser.ver.id .......... : { state .current_ser_ver_id }
577
- - New ser.ver.id .............. : { state .new_ser_ver_id }
579
+ - Latest version .............. : { state .latest_version }
580
+ - Next version ................ : { state .next_version }
581
+ - Latest ser.ver.id ........... : { state .latest_ser_ver_id }
582
+ - Next ser.ver.id ............. : { state .next_ser_ver_id }
578
583
''' )
579
584
580
585
@@ -623,16 +628,16 @@ def git_tag(version):
623
628
return f'v{ version } '
624
629
625
630
626
- def bump_release_ser_ver_id (current_id ):
631
+ def bump_release_ser_ver_id (latest_id ):
627
632
# The id format can be either 'A-00053' or 'AA-0053'
628
633
if len (config .ser_ver_id_prefix ) == 1 :
629
- ver_number = int (current_id [2 :])
634
+ ver_number = int (latest_id [2 :])
630
635
ser_format = '{:05d}'
631
636
else :
632
- ver_number = int (current_id [3 :])
637
+ ver_number = int (latest_id [3 :])
633
638
ser_format = '{:04d}'
634
639
v = config .ser_ver_id_prefix + '-' + ser_format .format (ver_number + 1 )
635
- debug (f'New serialization version id: { v } ' )
640
+ debug (f'Next serialization version id: { v } ' )
636
641
return v
637
642
638
643
@@ -768,14 +773,13 @@ def print_help():
768
773
print (f"""
769
774
This script is used to create a new release in a downstream fork of OTP. It will set both
770
775
the Maven version(2.7.0-entur-23) and the serialization-version-id(EN-0020) to a unique id
771
- using the fork project name. For the script to work the git remote name must match the
772
- GitHub 'owner' name.
776
+ using the provided configuration.
773
777
774
778
Release process overview
775
- 1. The configured release-branch is reset hard to the <base-revision>.
776
- 2. Then the labeled PRs are merged into the release-branch, if configured.
777
- 3. The config-branches are merged into the release-branch.
778
- 4. The pom.xml file is updated with a new version and serialization version id.
779
+ 1. The configured release-branch is reset hard to the <base-revision> script argument .
780
+ 2. Then the labeled PRs are merged into the release-branch [ if configured] .
781
+ 3. The config-branches are merged into the release-branch [if configured] .
782
+ 4. The pom.xml file is updated with a new version and serialization version id [if requiered] .
779
783
5. The release is tested, tagged and pushed to Git repo.
780
784
781
785
See the RELEASE_README.md for more details.
@@ -785,17 +789,18 @@ def print_help():
785
789
786
790
Arguments
787
791
<base-revision> : The base branch or commit to use as the base for the release. The
788
- 'otp/dev-2.x' is the most common base branch to use, but you can
789
- create a new release on top of any <commit>.
790
- This parameter is required unless option --release is used.
792
+ 'otp/dev-2.x' is the most common base branch to use, but you can create a
793
+ new release on top of any <commit>. This parameter is required unless
794
+ option --release is used.
791
795
792
796
Options
793
797
-h, --help : Print this help.
794
798
--debug : Run script with debug output enabled.
795
799
--dryRun : Run script locally, nothing is pushed to remote server.
796
- --release : Create a new release from the current local Git repo HEAD. It updates the
797
- maven-project-version and the serialization-version-id, creates a new tag
798
- and push the release. You should apply all fixes and commit BEFORE running
800
+ --release : Create a new release from the checked out local Git repo HEAD. It updates the
801
+ maven-project-version, but NOT the serialization-version-id. To increment the
802
+ serialization-version-id use the --serVerId option as well. This create a new
803
+ tag and push the release. You should apply all fixes and commit BEFORE running
799
804
this script. Can not be used with the <base-revision> argument set. The
800
805
'custom-release-extension' script is NOT run.
801
806
--serVerId : Force incrementation of the serialization version id.
0 commit comments