diff --git a/scripts/release_autoversioning.py b/scripts/release_autoversioning.py index 8ecdfb907..5eccad65d 100644 --- a/scripts/release_autoversioning.py +++ b/scripts/release_autoversioning.py @@ -1,34 +1,29 @@ - import configparser -def update_version_in_files(gnoll_ini_path, setup_cfg_path, project_toml_path): - # Read version from GNOLL.ini - config = configparser.ConfigParser() - config.read(gnoll_ini_path) - version = config['Meta Information']['version'] - - # Update version in setup.cfg - with open(setup_cfg_path, 'r') as f: +def update_version(path, find, replace): + with open(path, 'r') as f: + # Get every line lines = f.readlines() - - with open(setup_cfg_path, 'w') as f: + + with open(path, 'w', encoding='utf_8') as f: for line in lines: - if line.startswith('version ='): - f.write(f'version = {version}\n') + if find in line: + f.write(replace) else: f.write(line) - # Update version in Project.toml - with open(project_toml_path, 'r') as f: - lines = f.readlines() - with open(project_toml_path, 'w', encoding='utf_8') as f: - for line in lines: - if line.startswith('version ='): - f.write(f'version = "{version}"\n') - else: - f.write(line) +def update_version_in_files(gnoll_ini_path, setup_cfg_path, project_toml_path): + # Read version from GNOLL.ini + config = configparser.ConfigParser() + config.read(gnoll_ini_path) + version = config['Meta Information']['version'] + update_version(setup_cfg_path, 'version =', f'version = "{version}"\n') + update_version(project_toml_path, 'version =', f'version = "{version}"\n') + update_version("src/grammar/dice.yacc", 'printf("GNOLL', f'printf("GNOLL {version}")\n') + + gnoll_ini_path = 'GNOLL.ini' setup_cfg_path = 'src/python/setup.cfg' project_toml_path = 'GNOLL/src/julia/GNOLL/Project.toml'