From d76b18254a7f9e0d84958be7cf2faa59badfdf7f Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Thu, 17 Mar 2022 19:49:23 +0000 Subject: [PATCH] Add functionality for `v2 -> v1` backports --- .github/update-release-branch.py | 23 +++++++++++++++++++-- .github/workflows/update-release-branch.yml | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/update-release-branch.py b/.github/update-release-branch.py index ec8bdf75b..42479624a 100644 --- a/.github/update-release-branch.py +++ b/.github/update-release-branch.py @@ -193,12 +193,22 @@ def main(): required=True, help='The GitHub handle of the person who is conducting the release process.' ) + parser.add_argument( + '--perform-v2-to-v1-backport', + action='store_true', + help='Pass this flag if this release is a backport from v2 to v1.' + ) args = parser.parse_args() repo = Github(args.github_token).get_repo(args.repository_nwo) version = get_current_version() + if args.perform_v2_to_v1_backport: + # Change the version number to a v1 equivalent + version = get_current_version() + version = f'1{version[1:]}' + # Print what we intend to go print('Considering difference between ' + args.source_branch + ' and ' + args.target_branch) short_main_sha = run_git('rev-parse', '--short', ORIGIN + '/' + args.source_branch).strip() @@ -226,8 +236,17 @@ def main(): print('Creating branch ' + new_branch_name) run_git('checkout', '-b', new_branch_name, ORIGIN + '/' + args.source_branch) - print('Updating changelog') - update_changelog(version) + if args.perform_v2_to_v1_backport: + print(f'Setting version number to {version}') + subprocess.run(['npm', 'version', version]) + run_git('add', 'package.json', 'package-lock.json', 'runner/package.json', 'runner/package-lock.json') + + print('Migrating changelog notes from v2 to v1') + subprocess.run(['sed', '-i', 's/## 2./## 1./g', 'CHANGELOG.md']) + else: + # We don't need to do this for a v1 release, since the changelog has already been updated in the v2 branch. + print('Updating changelog') + update_changelog(version) # Create a commit that updates the CHANGELOG run_git('add', 'CHANGELOG.md') diff --git a/.github/workflows/update-release-branch.yml b/.github/workflows/update-release-branch.yml index 5271eda2e..ed8278e55 100644 --- a/.github/workflows/update-release-branch.yml +++ b/.github/workflows/update-release-branch.yml @@ -53,4 +53,5 @@ jobs: --repository-nwo ${{ github.repository }} \ --source-branch v2 \ --target-branch v1 \ - --conductor ${GITHUB_ACTOR} + --conductor ${GITHUB_ACTOR} \ + --perform-v2-to-v1-backport