Update version to 0.3.2 and add version update script#5
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the project version from 0.3.1 to 0.3.2 across multiple configuration files and introduces a Python script to automate version updates in the future. The changes ensure version consistency across the package metadata, documentation, and source code.
- Updated version number from 0.3.1 to 0.3.2 in all relevant files
- Added a version update automation script for future releases
- Removed GitHub release upload workflow step
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| yarp/init.py | Updated package version and added explanatory comments for preflight checks |
| update_version.py | New script to automatically update version numbers across project files |
| pyproject.toml | Updated project version in package configuration |
| docs/source/conf.py | Updated documentation release version |
| .github/workflows/pip_package.yml | Removed GitHub release upload workflow steps |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| version = sys.argv[1] if len(sys.argv) > 1 else None | ||
| if not version: | ||
| print("Usage: python update_version.py <new_version>") | ||
| sys.exit(1) |
There was a problem hiding this comment.
The script lacks input validation for the version parameter. Consider adding validation to ensure the version follows semantic versioning format (e.g., using a regex pattern like r'^\d+\.\d+\.\d+$') before attempting to update files.
| sys.exit(1) | |
| sys.exit(1) | |
| # Validate semantic versioning format | |
| if not re.match(r'^\d+\.\d+\.\d+$', version): | |
| print("Error: Version must follow semantic versioning (e.g., 1.2.3)") | |
| sys.exit(1) |
| content = PYPROJECT.read_text() | ||
| new_content = re.sub(r'version\s*=\s*"[^"]+"', f'version = "{version}"', content) | ||
| PYPROJECT.write_text(new_content) | ||
|
|
||
|
|
||
| def update_conf_py(version): | ||
| content = CONF_PY.read_text() | ||
| # Update 'release' and/or 'version' variables | ||
| new_content = re.sub(r'release\s*=\s*"[^"]+"', f'release = "{version}"', content) | ||
| new_content = re.sub( | ||
| r'version\s*=\s*"[^"]+"', f'version = "{version}"', new_content | ||
| ) | ||
| CONF_PY.write_text(new_content) | ||
|
|
||
|
|
||
| def update_init_py(version): | ||
| content = INIT_PY.read_text() | ||
| new_content = re.sub( | ||
| r'__version__\s*=\s*"[^"]+"', f'__version__ = "{version}"', content | ||
| ) | ||
| INIT_PY.write_text(new_content) |
There was a problem hiding this comment.
The functions don't handle file read/write errors or check if the regex substitution actually found and replaced content. Consider adding error handling and validation that the expected version pattern was found and updated.
| content = PYPROJECT.read_text() | |
| new_content = re.sub(r'version\s*=\s*"[^"]+"', f'version = "{version}"', content) | |
| PYPROJECT.write_text(new_content) | |
| def update_conf_py(version): | |
| content = CONF_PY.read_text() | |
| # Update 'release' and/or 'version' variables | |
| new_content = re.sub(r'release\s*=\s*"[^"]+"', f'release = "{version}"', content) | |
| new_content = re.sub( | |
| r'version\s*=\s*"[^"]+"', f'version = "{version}"', new_content | |
| ) | |
| CONF_PY.write_text(new_content) | |
| def update_init_py(version): | |
| content = INIT_PY.read_text() | |
| new_content = re.sub( | |
| r'__version__\s*=\s*"[^"]+"', f'__version__ = "{version}"', content | |
| ) | |
| INIT_PY.write_text(new_content) | |
| try: | |
| content = PYPROJECT.read_text() | |
| except Exception as e: | |
| print(f"Error reading {PYPROJECT}: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| new_content, count = re.subn(r'version\s*=\s*"[^"]+"', f'version = "{version}"', content) | |
| if count == 0: | |
| print(f"Error: version pattern not found in {PYPROJECT}", file=sys.stderr) | |
| sys.exit(1) | |
| try: | |
| PYPROJECT.write_text(new_content) | |
| except Exception as e: | |
| print(f"Error writing {PYPROJECT}: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| def update_conf_py(version): | |
| try: | |
| content = CONF_PY.read_text() | |
| except Exception as e: | |
| print(f"Error reading {CONF_PY}: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| # Update 'release' and/or 'version' variables | |
| new_content, release_count = re.subn(r'release\s*=\s*"[^"]+"', f'release = "{version}"', content) | |
| new_content, version_count = re.subn( | |
| r'version\s*=\s*"[^"]+"', f'version = "{version}"', new_content | |
| ) | |
| if release_count == 0 and version_count == 0: | |
| print(f"Error: neither 'release' nor 'version' pattern found in {CONF_PY}", file=sys.stderr) | |
| sys.exit(1) | |
| try: | |
| CONF_PY.write_text(new_content) | |
| except Exception as e: | |
| print(f"Error writing {CONF_PY}: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| def update_init_py(version): | |
| try: | |
| content = INIT_PY.read_text() | |
| except Exception as e: | |
| print(f"Error reading {INIT_PY}: {e}", file=sys.stderr) | |
| sys.exit(1) | |
| new_content, count = re.subn( | |
| r'__version__\s*=\s*"[^"]+"', f'__version__ = "{version}"', content | |
| ) | |
| if count == 0: | |
| print(f"Error: __version__ pattern not found in {INIT_PY}", file=sys.stderr) | |
| sys.exit(1) | |
| try: | |
| INIT_PY.write_text(new_content) | |
| except Exception as e: | |
| print(f"Error writing {INIT_PY}: {e}", file=sys.stderr) | |
| sys.exit(1) |
No description provided.