From ebcfa613ca8b68eab7a3c55f63aa5a1da367a0e8 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 27 Jun 2023 11:48:17 +0200 Subject: [PATCH 1/7] [Draft] Script: New Version Adding a script to update all version notes programmatically for releases. --- new_version.sh | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100755 new_version.sh diff --git a/new_version.sh b/new_version.sh new file mode 100755 index 0000000000..5ec6b31514 --- /dev/null +++ b/new_version.sh @@ -0,0 +1,175 @@ +#!/usr/bin/env python3 +# +# Copyright 2021-2023 Axel Huebl +# +# This file is part of openPMD-api. +# + +# This file is a maintainer tool to bump the versions inside openPMD-api's +# source directory at all places where necessary. +# +import datetime +from pathlib import Path +import re +import sys + +import requests + +try: + from configupdater import ConfigUpdater +except ImportError: + print("Warning: Cannot update .ini files without 'configupdater'") + print("Consider running 'python -m pip install configupdater'") + ConfigUpdater = None + sys.exit(1) + + +# Maintainer Inputs ########################################################### + +print("""Hi there, this is an openPMD maintainer tool to update the source +code of openPMD-api to a new version. +For it to work, you need write access on the source directory and +you should be working in a clean git branch without ongoing +rebase/merge/conflict resolves and without unstaged changes.""") + +# check source dir +REPO_DIR = Path(__file__).parent.parent.parent.absolute() +print(f"\nYour current source directory is: {REPO_DIR}") + +REPLY = input("Are you sure you want to continue? [Y/n] ") +print() +if not REPLY in ["Y", "y", ""]: + print("You did not confirm with 'y', aborting.") + sys.exit(1) + + +# New Version ################################################################# + +# AMReX development HEAD +amrex_gh = requests.get('https://api.github.com/repos/AMReX-Codes/amrex/commits/development') +amrex_HEAD = amrex_gh.json()["sha"] + +MAJOR = input("MAJOR version? (e.g., 1) ") +MINOR = input("MINOR version? (e.g., 0) ") +PATCH = input("PATCH version? (e.g., 0) ") +SUFFIX = input("SUFFIX? (e.g., dev) ") +if SUFFIX != "": + SUFFIX_STR = f"-{SUFFIX}" + +VERSION_STR_NOSUFFIX=f"{MAJOR}.{MINOR}{PATCH}" +VERSION_STR=f"{MAJOR}.{MINOR}.{PATCH}{SUFFIX_STR}" + +echo +echo "Your new version is: ${VERSION_STR}" +echo + +read -p "Is this information correct? Will now start updating! [y/N] " -r +echo + + +# Ask for new ################################################################# + +print("""We will now run a few sed commands on your source directory. +Please answer the following questions about the version number +you want to require from AMReX:\n""") + +print(f"Currently, WarpX builds against this AMReX commit/branch/sha: {amrex_branch}") +print(f"AMReX HEAD commit (development branch): {amrex_HEAD}") +amrex_new_branch = input(f"Update AMReX commit/branch/sha: ").strip() +if not amrex_new_branch: + amrex_new_branch = amrex_branch + print(f"--> Nothing entered, will keep: {amrex_branch}") +print() + +print(f"Currently, a pre-installed AMReX is required at least at version: {amrex_minimal}") +today = datetime.date.today().strftime("%y.%m") +amrex_new_minimal = input(f"New minimal AMReX version (e.g. {today})? ").strip() +if not amrex_new_minimal: + amrex_new_minimal = amrex_minimal + print(f"--> Nothing entered, will keep: {amrex_minimal}") + +print() +print(f"New AMReX commit/branch/sha: {amrex_new_branch}") +print(f"New minimal AMReX version: {amrex_new_minimal}\n") + +REPLY = input("Is this information correct? Will now start updating! [y/N] ") +print() +if not REPLY in ["Y", "y"]: + print("You did not confirm with 'y', aborting.") + sys.exit(1) + + +# Updates ##################################################################### + +# run_test.sh (used also for Azure Pipelines) +run_test_path = str(REPO_DIR.joinpath("run_test.sh")) +with open(run_test_path, encoding='utf-8') as f: + run_test_content = f.read() + # branch/commit/tag (git fetcher) version + # cd amrex && git checkout COMMIT_TAG_OR_BRANCH && cd - + run_test_content = re.sub( + r'(.*cd\s+amrex.+git checkout\s+--detach\s+)(.+)(\s+&&\s.*)', + r'\g<1>{}\g<3>'.format(amrex_new_branch), + run_test_content, flags = re.MULTILINE) + +with open(run_test_path, "w", encoding='utf-8') as f: + f.write(run_test_content) + +# CI: legacy build check in .github/workflows/cuda.yml +ci_gnumake_path = str(REPO_DIR.joinpath(".github/workflows/cuda.yml")) +with open(ci_gnumake_path, encoding='utf-8') as f: + ci_gnumake_content = f.read() + # branch/commit/tag (git fetcher) version + # cd ../amrex && git checkout COMMIT_TAG_OR_BRANCH && cd - + ci_gnumake_content = re.sub( + r'(.*cd\s+\.\./amrex.+git checkout\s+--detach\s+)(.+)(\s+&&\s.*)', + r'\g<1>{}\g<3>'.format(amrex_new_branch), + ci_gnumake_content, flags = re.MULTILINE) + +with open(ci_gnumake_path, "w", encoding='utf-8') as f: + f.write(ci_gnumake_content) + +if ConfigUpdater is not None: + # WarpX-tests.ini + tests_ini_path = str(REPO_DIR.joinpath("Regression/WarpX-tests.ini")) + cp = ConfigUpdater() + cp.optionxform = str + cp.read(tests_ini_path) + cp['AMReX']['branch'].value = amrex_new_branch + cp.update_file() + + # WarpX-GPU-tests.ini + tests_gpu_ini_path = str(REPO_DIR.joinpath("Regression/WarpX-GPU-tests.ini")) + cp = ConfigUpdater() + cp.optionxform = str + cp.read(tests_gpu_ini_path) + cp['AMReX']['branch'].value = amrex_new_branch + cp.update_file() + +# WarpX references to AMReX: cmake/dependencies/AMReX.cmake +with open(amrex_cmake_path, encoding='utf-8') as f: + amrex_cmake_content = f.read() + + # branch/commit/tag (git fetcher) version + # set(WarpX_amrex_branch "development" ... + amrex_cmake_content = re.sub( + r'(.*set\(WarpX_amrex_branch\s+")(.+)("\s+.*)', + r'\g<1>{}\g<3>'.format(amrex_new_branch), + amrex_cmake_content, flags = re.MULTILINE) + + # minimal (external) version + # find_package(AMReX YY.MM CONFIG ... + amrex_cmake_content = re.sub( + r'(.*find_package\(AMReX\s+)(.+)(\s+CONFIG\s+.*)', + r'\g<1>{}\g<3>'.format(amrex_new_minimal), + amrex_cmake_content, flags = re.MULTILINE) + +with open(amrex_cmake_path, "w", encoding='utf-8') as f: + f.write(amrex_cmake_content) + + +# Epilogue #################################################################### + +print("""Done. Please check your source, e.g. via + git diff +now and commit the changes if no errors occurred.""") From d3fe21a5eb4d5c725012d2095725f48962c9424c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 2 Aug 2024 15:04:18 +0200 Subject: [PATCH 2/7] wip --- new_version.sh => new_version.py | 114 +++++++++++++++++++------------ 1 file changed, 70 insertions(+), 44 deletions(-) rename new_version.sh => new_version.py (62%) diff --git a/new_version.sh b/new_version.py similarity index 62% rename from new_version.sh rename to new_version.py index 5ec6b31514..57f891523b 100755 --- a/new_version.sh +++ b/new_version.py @@ -8,7 +8,6 @@ # This file is a maintainer tool to bump the versions inside openPMD-api's # source directory at all places where necessary. # -import datetime from pathlib import Path import re import sys @@ -33,7 +32,8 @@ rebase/merge/conflict resolves and without unstaged changes.""") # check source dir -REPO_DIR = Path(__file__).parent.parent.parent.absolute() +# REPO_DIR = Path(__file__).parent.parent.parent.absolute() +REPO_DIR = Path(__file__).parent.absolute() print(f"\nYour current source directory is: {REPO_DIR}") REPLY = input("Are you sure you want to continue? [Y/n] ") @@ -46,25 +46,34 @@ # New Version ################################################################# # AMReX development HEAD -amrex_gh = requests.get('https://api.github.com/repos/AMReX-Codes/amrex/commits/development') -amrex_HEAD = amrex_gh.json()["sha"] +openpmd_gh = requests.get('https://api.github.com/repos/openPMD/openPMD-api/commits/dev') +openpmd_HEAD = openpmd_gh.json()["sha"] MAJOR = input("MAJOR version? (e.g., 1) ") MINOR = input("MINOR version? (e.g., 0) ") PATCH = input("PATCH version? (e.g., 0) ") -SUFFIX = input("SUFFIX? (e.g., dev) ") -if SUFFIX != "": - SUFFIX_STR = f"-{SUFFIX}" -VERSION_STR_NOSUFFIX=f"{MAJOR}.{MINOR}{PATCH}" -VERSION_STR=f"{MAJOR}.{MINOR}.{PATCH}{SUFFIX_STR}" +VERSION_STR=f"{MAJOR}.{MINOR}.{PATCH}" -echo -echo "Your new version is: ${VERSION_STR}" -echo +print() +print(f"Your new version is: {VERSION_STR}") + +with open(str(REPO_DIR.joinpath('README.md')), encoding='utf-8') as f: + for line in f: + match = re.search(r'find_package.*openPMD *([^ ]*) *CONFIG\).*', line) + if match: + OLD_VERSION_STR = match.group(1) + break + +print(f"The old version is: {OLD_VERSION_STR}") +print() -read -p "Is this information correct? Will now start updating! [y/N] " -r -echo + +REPLY=input("Is this information correct? Will now start updating! [y/N] ") +print() +if not REPLY in ["Y", "y", ""]: + print("You did not confirm with 'y', aborting.") + sys.exit(1) # Ask for new ################################################################# @@ -73,24 +82,24 @@ Please answer the following questions about the version number you want to require from AMReX:\n""") -print(f"Currently, WarpX builds against this AMReX commit/branch/sha: {amrex_branch}") -print(f"AMReX HEAD commit (development branch): {amrex_HEAD}") -amrex_new_branch = input(f"Update AMReX commit/branch/sha: ").strip() -if not amrex_new_branch: - amrex_new_branch = amrex_branch - print(f"--> Nothing entered, will keep: {amrex_branch}") -print() - -print(f"Currently, a pre-installed AMReX is required at least at version: {amrex_minimal}") -today = datetime.date.today().strftime("%y.%m") -amrex_new_minimal = input(f"New minimal AMReX version (e.g. {today})? ").strip() -if not amrex_new_minimal: - amrex_new_minimal = amrex_minimal - print(f"--> Nothing entered, will keep: {amrex_minimal}") - -print() -print(f"New AMReX commit/branch/sha: {amrex_new_branch}") -print(f"New minimal AMReX version: {amrex_new_minimal}\n") +# print(f"Currently, WarpX builds against this AMReX commit/branch/sha: {amrex_branch}") +print(f"openPMD HEAD commit (dev branch): {openpmd_HEAD}") +# amrex_new_branch = input(f"Update AMReX commit/branch/sha: ").strip() +# if not amrex_new_branch: +# amrex_new_branch = amrex_branch +# print(f"--> Nothing entered, will keep: {amrex_branch}") +# print() + +# print(f"Currently, a pre-installed AMReX is required at least at version: {amrex_minimal}") +# today = datetime.date.today().strftime("%y.%m") +# amrex_new_minimal = input(f"New minimal AMReX version (e.g. {today})? ").strip() +# if not amrex_new_minimal: +# amrex_new_minimal = amrex_minimal +# print(f"--> Nothing entered, will keep: {amrex_minimal}") + +# print() +# print(f"New AMReX commit/branch/sha: {amrex_new_branch}") +# print(f"New minimal AMReX version: {amrex_new_minimal}\n") REPLY = input("Is this information correct? Will now start updating! [y/N] ") print() @@ -102,18 +111,35 @@ # Updates ##################################################################### # run_test.sh (used also for Azure Pipelines) -run_test_path = str(REPO_DIR.joinpath("run_test.sh")) -with open(run_test_path, encoding='utf-8') as f: - run_test_content = f.read() - # branch/commit/tag (git fetcher) version - # cd amrex && git checkout COMMIT_TAG_OR_BRANCH && cd - - run_test_content = re.sub( - r'(.*cd\s+amrex.+git checkout\s+--detach\s+)(.+)(\s+&&\s.*)', - r'\g<1>{}\g<3>'.format(amrex_new_branch), - run_test_content, flags = re.MULTILINE) - -with open(run_test_path, "w", encoding='utf-8') as f: - f.write(run_test_content) +cmakelists_path = str(REPO_DIR.joinpath("CMakeLists.txt")) +with open(cmakelists_path, encoding='utf-8') as f: + cmakelists_content = f.read() + cmakelists_content = re.sub( + r'^(project.*openPMD.*VERSION *)(.*)(\).*)$', + r'\g<1>{}\g<3>'.format(VERSION_STR_NOSUFFIX), + cmakelists_content, + flags = re.MULTILINE + ) + +with open(cmakelists_path, "w", encoding='utf-8') as f: + f.write(cmakelists_content) + +def generic_replace(filename): + filename = str(REPO_DIR.joinpath(filename)) + with open(filename, encoding='utf-8') as f: + content = f.read() + content = re.sub( + re.escape(OLD_VERSION_STR), + VERSION_STR, + content + ) + + with open(filename, "w", encoding='utf-8') as f: + f.write(content) + +for file in ['docs/source/dev/linking.rst', 'README.md']: + generic_replace(file) +sys.exit(0) # CI: legacy build check in .github/workflows/cuda.yml ci_gnumake_path = str(REPO_DIR.joinpath(".github/workflows/cuda.yml")) From f4d5eae2947f262966a38388b9c5a9311c1805b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 2 Aug 2024 15:07:26 +0200 Subject: [PATCH 3/7] wip --- new_version.py | 115 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/new_version.py b/new_version.py index 57f891523b..8aa3b18366 100755 --- a/new_version.py +++ b/new_version.py @@ -25,11 +25,13 @@ # Maintainer Inputs ########################################################### -print("""Hi there, this is an openPMD maintainer tool to update the source +print( + """Hi there, this is an openPMD maintainer tool to update the source code of openPMD-api to a new version. For it to work, you need write access on the source directory and you should be working in a clean git branch without ongoing -rebase/merge/conflict resolves and without unstaged changes.""") +rebase/merge/conflict resolves and without unstaged changes.""" +) # check source dir # REPO_DIR = Path(__file__).parent.parent.parent.absolute() @@ -46,21 +48,25 @@ # New Version ################################################################# # AMReX development HEAD -openpmd_gh = requests.get('https://api.github.com/repos/openPMD/openPMD-api/commits/dev') +openpmd_gh = requests.get( + "https://api.github.com/repos/openPMD/openPMD-api/commits/dev" +) openpmd_HEAD = openpmd_gh.json()["sha"] MAJOR = input("MAJOR version? (e.g., 1) ") MINOR = input("MINOR version? (e.g., 0) ") PATCH = input("PATCH version? (e.g., 0) ") +SUFFIX = input("SUFFIX? (e.g., dev) ") -VERSION_STR=f"{MAJOR}.{MINOR}.{PATCH}" +VERSION_STR = f"{MAJOR}.{MINOR}.{PATCH}" +VERSION_STR_SUFFIX = VERSION_STR + (f"-{SUFFIX}" if SUFFIX else "") print() -print(f"Your new version is: {VERSION_STR}") +print(f"Your new version is: {VERSION_STR_SUFFIX}") -with open(str(REPO_DIR.joinpath('README.md')), encoding='utf-8') as f: +with open(str(REPO_DIR.joinpath("README.md")), encoding="utf-8") as f: for line in f: - match = re.search(r'find_package.*openPMD *([^ ]*) *CONFIG\).*', line) + match = re.search(r"find_package.*openPMD *([^ ]*) *CONFIG\).*", line) if match: OLD_VERSION_STR = match.group(1) break @@ -69,7 +75,7 @@ print() -REPLY=input("Is this information correct? Will now start updating! [y/N] ") +REPLY = input("Is this information correct? Will now start updating! [y/N] ") print() if not REPLY in ["Y", "y", ""]: print("You did not confirm with 'y', aborting.") @@ -78,9 +84,11 @@ # Ask for new ################################################################# -print("""We will now run a few sed commands on your source directory. +print( + """We will now run a few sed commands on your source directory. Please answer the following questions about the version number -you want to require from AMReX:\n""") +you want to require from AMReX:\n""" +) # print(f"Currently, WarpX builds against this AMReX commit/branch/sha: {amrex_branch}") print(f"openPMD HEAD commit (dev branch): {openpmd_HEAD}") @@ -112,47 +120,70 @@ # run_test.sh (used also for Azure Pipelines) cmakelists_path = str(REPO_DIR.joinpath("CMakeLists.txt")) -with open(cmakelists_path, encoding='utf-8') as f: +with open(cmakelists_path, encoding="utf-8") as f: cmakelists_content = f.read() cmakelists_content = re.sub( - r'^(project.*openPMD.*VERSION *)(.*)(\).*)$', - r'\g<1>{}\g<3>'.format(VERSION_STR_NOSUFFIX), + r"^(project.*openPMD.*VERSION *)(.*)(\).*)$", + r"\g<1>{}\g<3>".format(VERSION_STR), cmakelists_content, - flags = re.MULTILINE + flags=re.MULTILINE, ) -with open(cmakelists_path, "w", encoding='utf-8') as f: +with open(cmakelists_path, "w", encoding="utf-8") as f: f.write(cmakelists_content) + def generic_replace(filename): filename = str(REPO_DIR.joinpath(filename)) - with open(filename, encoding='utf-8') as f: + with open(filename, encoding="utf-8") as f: content = f.read() - content = re.sub( - re.escape(OLD_VERSION_STR), - VERSION_STR, - content - ) + content = re.sub(re.escape(OLD_VERSION_STR), VERSION_STR, content) - with open(filename, "w", encoding='utf-8') as f: + with open(filename, "w", encoding="utf-8") as f: f.write(content) -for file in ['docs/source/dev/linking.rst', 'README.md']: + +for file in ["docs/source/dev/linking.rst", "README.md"]: generic_replace(file) + +version_hpp_path = str(REPO_DIR.joinpath("include/openPMD/version.hpp")) +with open(version_hpp_path, encoding="utf-8") as f: + version_hpp_content = f.read() + + def replace(key, value): + global version_hpp_content + version_hpp_content = re.sub( + r"^(#define OPENPMDAPI_VERSION_{}) .*$".format(re.escape(key)), + r"\1 {}".format(value), + version_hpp_content, + flags=re.MULTILINE, + ) + + replace("MAJOR", MAJOR) + replace("MINOR", MINOR) + replace("PATCH", PATCH) + replace("LABEL", '"{}"'.format(SUFFIX)) + +with open(version_hpp_path, "w", encoding="utf-8") as f: + f.write(version_hpp_content) + + sys.exit(0) # CI: legacy build check in .github/workflows/cuda.yml ci_gnumake_path = str(REPO_DIR.joinpath(".github/workflows/cuda.yml")) -with open(ci_gnumake_path, encoding='utf-8') as f: +with open(ci_gnumake_path, encoding="utf-8") as f: ci_gnumake_content = f.read() # branch/commit/tag (git fetcher) version # cd ../amrex && git checkout COMMIT_TAG_OR_BRANCH && cd - ci_gnumake_content = re.sub( - r'(.*cd\s+\.\./amrex.+git checkout\s+--detach\s+)(.+)(\s+&&\s.*)', - r'\g<1>{}\g<3>'.format(amrex_new_branch), - ci_gnumake_content, flags = re.MULTILINE) + r"(.*cd\s+\.\./amrex.+git checkout\s+--detach\s+)(.+)(\s+&&\s.*)", + r"\g<1>{}\g<3>".format(amrex_new_branch), + ci_gnumake_content, + flags=re.MULTILINE, + ) -with open(ci_gnumake_path, "w", encoding='utf-8') as f: +with open(ci_gnumake_path, "w", encoding="utf-8") as f: f.write(ci_gnumake_content) if ConfigUpdater is not None: @@ -161,7 +192,7 @@ def generic_replace(filename): cp = ConfigUpdater() cp.optionxform = str cp.read(tests_ini_path) - cp['AMReX']['branch'].value = amrex_new_branch + cp["AMReX"]["branch"].value = amrex_new_branch cp.update_file() # WarpX-GPU-tests.ini @@ -169,33 +200,39 @@ def generic_replace(filename): cp = ConfigUpdater() cp.optionxform = str cp.read(tests_gpu_ini_path) - cp['AMReX']['branch'].value = amrex_new_branch + cp["AMReX"]["branch"].value = amrex_new_branch cp.update_file() # WarpX references to AMReX: cmake/dependencies/AMReX.cmake -with open(amrex_cmake_path, encoding='utf-8') as f: +with open(amrex_cmake_path, encoding="utf-8") as f: amrex_cmake_content = f.read() # branch/commit/tag (git fetcher) version # set(WarpX_amrex_branch "development" ... amrex_cmake_content = re.sub( r'(.*set\(WarpX_amrex_branch\s+")(.+)("\s+.*)', - r'\g<1>{}\g<3>'.format(amrex_new_branch), - amrex_cmake_content, flags = re.MULTILINE) + r"\g<1>{}\g<3>".format(amrex_new_branch), + amrex_cmake_content, + flags=re.MULTILINE, + ) # minimal (external) version # find_package(AMReX YY.MM CONFIG ... amrex_cmake_content = re.sub( - r'(.*find_package\(AMReX\s+)(.+)(\s+CONFIG\s+.*)', - r'\g<1>{}\g<3>'.format(amrex_new_minimal), - amrex_cmake_content, flags = re.MULTILINE) + r"(.*find_package\(AMReX\s+)(.+)(\s+CONFIG\s+.*)", + r"\g<1>{}\g<3>".format(amrex_new_minimal), + amrex_cmake_content, + flags=re.MULTILINE, + ) -with open(amrex_cmake_path, "w", encoding='utf-8') as f: +with open(amrex_cmake_path, "w", encoding="utf-8") as f: f.write(amrex_cmake_content) # Epilogue #################################################################### -print("""Done. Please check your source, e.g. via +print( + """Done. Please check your source, e.g. via git diff -now and commit the changes if no errors occurred.""") +now and commit the changes if no errors occurred.""" +) From 501a78f2d842c2edc0d6b5480f78e6c66cf615ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Fri, 2 Aug 2024 16:11:46 +0200 Subject: [PATCH 4/7] Remove unnecessary Amrex stuff --- new_version.py | 108 ------------------------------------------------- 1 file changed, 108 deletions(-) diff --git a/new_version.py b/new_version.py index 8aa3b18366..852ae91ec6 100755 --- a/new_version.py +++ b/new_version.py @@ -12,17 +12,6 @@ import re import sys -import requests - -try: - from configupdater import ConfigUpdater -except ImportError: - print("Warning: Cannot update .ini files without 'configupdater'") - print("Consider running 'python -m pip install configupdater'") - ConfigUpdater = None - sys.exit(1) - - # Maintainer Inputs ########################################################### print( @@ -44,15 +33,6 @@ print("You did not confirm with 'y', aborting.") sys.exit(1) - -# New Version ################################################################# - -# AMReX development HEAD -openpmd_gh = requests.get( - "https://api.github.com/repos/openPMD/openPMD-api/commits/dev" -) -openpmd_HEAD = openpmd_gh.json()["sha"] - MAJOR = input("MAJOR version? (e.g., 1) ") MINOR = input("MINOR version? (e.g., 0) ") PATCH = input("PATCH version? (e.g., 0) ") @@ -90,32 +70,6 @@ you want to require from AMReX:\n""" ) -# print(f"Currently, WarpX builds against this AMReX commit/branch/sha: {amrex_branch}") -print(f"openPMD HEAD commit (dev branch): {openpmd_HEAD}") -# amrex_new_branch = input(f"Update AMReX commit/branch/sha: ").strip() -# if not amrex_new_branch: -# amrex_new_branch = amrex_branch -# print(f"--> Nothing entered, will keep: {amrex_branch}") -# print() - -# print(f"Currently, a pre-installed AMReX is required at least at version: {amrex_minimal}") -# today = datetime.date.today().strftime("%y.%m") -# amrex_new_minimal = input(f"New minimal AMReX version (e.g. {today})? ").strip() -# if not amrex_new_minimal: -# amrex_new_minimal = amrex_minimal -# print(f"--> Nothing entered, will keep: {amrex_minimal}") - -# print() -# print(f"New AMReX commit/branch/sha: {amrex_new_branch}") -# print(f"New minimal AMReX version: {amrex_new_minimal}\n") - -REPLY = input("Is this information correct? Will now start updating! [y/N] ") -print() -if not REPLY in ["Y", "y"]: - print("You did not confirm with 'y', aborting.") - sys.exit(1) - - # Updates ##################################################################### # run_test.sh (used also for Azure Pipelines) @@ -167,68 +121,6 @@ def replace(key, value): with open(version_hpp_path, "w", encoding="utf-8") as f: f.write(version_hpp_content) - -sys.exit(0) - -# CI: legacy build check in .github/workflows/cuda.yml -ci_gnumake_path = str(REPO_DIR.joinpath(".github/workflows/cuda.yml")) -with open(ci_gnumake_path, encoding="utf-8") as f: - ci_gnumake_content = f.read() - # branch/commit/tag (git fetcher) version - # cd ../amrex && git checkout COMMIT_TAG_OR_BRANCH && cd - - ci_gnumake_content = re.sub( - r"(.*cd\s+\.\./amrex.+git checkout\s+--detach\s+)(.+)(\s+&&\s.*)", - r"\g<1>{}\g<3>".format(amrex_new_branch), - ci_gnumake_content, - flags=re.MULTILINE, - ) - -with open(ci_gnumake_path, "w", encoding="utf-8") as f: - f.write(ci_gnumake_content) - -if ConfigUpdater is not None: - # WarpX-tests.ini - tests_ini_path = str(REPO_DIR.joinpath("Regression/WarpX-tests.ini")) - cp = ConfigUpdater() - cp.optionxform = str - cp.read(tests_ini_path) - cp["AMReX"]["branch"].value = amrex_new_branch - cp.update_file() - - # WarpX-GPU-tests.ini - tests_gpu_ini_path = str(REPO_DIR.joinpath("Regression/WarpX-GPU-tests.ini")) - cp = ConfigUpdater() - cp.optionxform = str - cp.read(tests_gpu_ini_path) - cp["AMReX"]["branch"].value = amrex_new_branch - cp.update_file() - -# WarpX references to AMReX: cmake/dependencies/AMReX.cmake -with open(amrex_cmake_path, encoding="utf-8") as f: - amrex_cmake_content = f.read() - - # branch/commit/tag (git fetcher) version - # set(WarpX_amrex_branch "development" ... - amrex_cmake_content = re.sub( - r'(.*set\(WarpX_amrex_branch\s+")(.+)("\s+.*)', - r"\g<1>{}\g<3>".format(amrex_new_branch), - amrex_cmake_content, - flags=re.MULTILINE, - ) - - # minimal (external) version - # find_package(AMReX YY.MM CONFIG ... - amrex_cmake_content = re.sub( - r"(.*find_package\(AMReX\s+)(.+)(\s+CONFIG\s+.*)", - r"\g<1>{}\g<3>".format(amrex_new_minimal), - amrex_cmake_content, - flags=re.MULTILINE, - ) - -with open(amrex_cmake_path, "w", encoding="utf-8") as f: - f.write(amrex_cmake_content) - - # Epilogue #################################################################### print( From 47e32a45a67f6e6b19e4d9dc1c29a7563bbffcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 5 Aug 2024 10:45:19 +0200 Subject: [PATCH 5/7] Code style --- new_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/new_version.py b/new_version.py index 852ae91ec6..9583eb9f9d 100755 --- a/new_version.py +++ b/new_version.py @@ -29,7 +29,7 @@ REPLY = input("Are you sure you want to continue? [Y/n] ") print() -if not REPLY in ["Y", "y", ""]: +if REPLY not in ["Y", "y", ""]: print("You did not confirm with 'y', aborting.") sys.exit(1) @@ -57,7 +57,7 @@ REPLY = input("Is this information correct? Will now start updating! [y/N] ") print() -if not REPLY in ["Y", "y", ""]: +if REPLY not in ["Y", "y", ""]: print("You did not confirm with 'y', aborting.") sys.exit(1) From b35a6cd365f5cc2df7ea42e1b836e2245ec7e089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 5 Aug 2024 10:47:55 +0200 Subject: [PATCH 6/7] Some cleanup --- new_version.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/new_version.py b/new_version.py index 9583eb9f9d..59f2e4e49d 100755 --- a/new_version.py +++ b/new_version.py @@ -44,6 +44,9 @@ print() print(f"Your new version is: {VERSION_STR_SUFFIX}") +# Recover the old version from the Readme. +# Do not use CMakeLists.txt as it might already contain the upcoming version +# code. with open(str(REPO_DIR.joinpath("README.md")), encoding="utf-8") as f: for line in f: match = re.search(r"find_package.*openPMD *([^ ]*) *CONFIG\).*", line) @@ -64,11 +67,7 @@ # Ask for new ################################################################# -print( - """We will now run a few sed commands on your source directory. -Please answer the following questions about the version number -you want to require from AMReX:\n""" -) +print("""We will now run a few sed commands on your source directory.\n""") # Updates ##################################################################### From e7ce248ba9097a1d2071e1e0415f5a3d90fa1900 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 18 Sep 2024 11:10:50 -0700 Subject: [PATCH 7/7] Add docs --- docs/source/index.rst | 3 +- .../{release.rst => release_channels.rst} | 6 ++- docs/source/maintenance/release_github.rst | 53 +++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) rename docs/source/maintenance/{release.rst => release_channels.rst} (94%) create mode 100644 docs/source/maintenance/release_github.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 7b7f050069..e9491afe5b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -166,4 +166,5 @@ Maintenance :maxdepth: 1 :hidden: - maintenance/release + maintenance/release_github + maintenance/release_channels diff --git a/docs/source/maintenance/release.rst b/docs/source/maintenance/release_channels.rst similarity index 94% rename from docs/source/maintenance/release.rst rename to docs/source/maintenance/release_channels.rst index 31f9f61b80..bd40f7f784 100644 --- a/docs/source/maintenance/release.rst +++ b/docs/source/maintenance/release_channels.rst @@ -1,8 +1,10 @@ -.. _maintenance-release: +.. _maintenance-release-channels: Release Channels ================ +After tagging and releasing a new openPMD-api version on GitHub, we update package managers that ship openPMD-api. + Spack ----- @@ -15,7 +17,7 @@ Example workflow for a new release: - https://github.com/spack/spack/pull/14018 -Please ping `@ax3l `_ in your pull-request. +Please ping `@ax3l `__ in your pull-request. Conda-Forge diff --git a/docs/source/maintenance/release_github.rst b/docs/source/maintenance/release_github.rst new file mode 100644 index 0000000000..cca163cde6 --- /dev/null +++ b/docs/source/maintenance/release_github.rst @@ -0,0 +1,53 @@ +.. _maintenance-release-github: + +New Version on GitHub +===================== + +These are the steps we perform to create a new openPMD-api release. + +Regular Release +--------------- + +As a first step, we merge in all pull requests and resolve all issued that we have assigned to the release's "Milestone" on GitHub. +For example, here are all `issues and pull requests `__ on the version ``0.16.0`` release. + +Then, we prepare a pull request that updates the ``CHANGELOG.rst`` and upgrade guide in ``NEWS.rst``, example PR: `Release notes: 0.16 `__ +In the same PR, we bump up the version in CMake files and documentation using our ``new_version.py`` script. + +Once the PR is merged, we: + +#. Wait for the CI to finish: there will be one more auto-commit added to the ``dev`` branch, updating out ``.pyi`` stub files +#. Pull the latest ``dev`` branch to our local machine +#. Add a GPG-signed tag, e.g., ``git tag -s 0.16.0``: see old releases for the format of this tag, e.g., use ``git show 0.15.0``. The text is from the top of ``CHANGELOG.rst``. +#. Upload the GPG-signed tag to mainline, e.g., ``git push -u mainline 0.16.0`` +#. Click `Draft a new release `__ on GitHub, select the newly created tag. + Fill the text fields using the same format that you see for `earlier releases `__, again, based on the top of the text in ``CHANGELOG.rst``. + Skip the DOI badge for this release step. +#. If you don't have GPG properly set up for your git, then you can just do the last step, which then also creates a tag. + Be sure to use the same version scheme for the tag, i.e., we do *not* prefix our tags with ``v`` or something of that kind! +#. Go to `Rodare `__ and wait for the release to arrive. + If there are issues, contact Rodare/HZDR IT support and check under `Settings - Webhooks `__ if the release was delivered. +#. Once the Rodare DOI is auto-created, click on the badge on the right hand side of the page, copy the Markdown code, and edit your `newly created release `__ text on GitHub to add the badge as you see in earlier releases. + +That's it! + + +Backport (Bugfix) Release +------------------------- + +For bugfix releases, we generally follow the same workflow as for regular releases. + +The main difference is that we: + +#. Start a new branch from the release we want to backport to. + We name the branch ``release-``, e.g., backports on the ``0.15.0`` release for a ``0.15.1`` release are named ``release-0.15.1``. +#. We add pull requests (usually we ``git cherry-pick`` commits) to that branch until we have all fixes collected. + Backport releases try to not add features and to not break APIs! +#. Then, we follow the same workflow as above, but we tag on the ``release-`` branch instead of the ``dev`` branch. +#. Once we uploaded the new tag to mainline and created the GitHub release, we remove the ``release-`` branch from our mainline repo. + The new tag we added contains all history we need if we wanted to do a follow-up bugfix, e.g., a ``release-0.15.2`` branch based on the ``0.15.1`` release. + +As general guidance, we usually only fix bugs on the *latest* regular release. +Don't sweat it - if it is too hard to backport a fix, consider doing a timely new regular version release. + +That's it!