diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 14e662112..7a63e8dea 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -67,9 +67,6 @@ jobs: needs: eval-changes with: python-versions-linux: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]' - # Since the test suite takes ~4 minutes to complete on windows, and windows is billed higher - # we are only going to run it on the oldest version of python we support. The older version - # will be the most likely area to fail as newer minor versions maintain compatibility. python-versions-windows: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]' files-changed: ${{ needs.eval-changes.outputs.any-file-changes }} build-files-changed: ${{ needs.eval-changes.outputs.build-changes }} @@ -116,6 +113,22 @@ jobs: name: ${{ needs.validate.outputs.distribution-artifacts }} path: dist + - name: Evaluate | Determine Next Version + id: version + uses: ./ + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + root_options: "-v --noop" + + - name: Release | Bump Version in Docs + if: steps.version.outputs.released == 'true' && steps.version.outputs.is_prerelease == 'false' + env: + NEW_VERSION: ${{ steps.version.outputs.version }} + NEW_RELEASE_TAG: ${{ steps.version.outputs.tag }} + run: | + python -m scripts.bump_version_in_docs + git add docs/* + - name: Release | Python Semantic Release id: release uses: ./ diff --git a/CHANGELOG.md b/CHANGELOG.md index 38439a798..2e4a8c2aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,27 @@ # CHANGELOG +## v9.16.1 (2025-01-12) + +### Bug Fixes + +- **parser-custom**: Handle relative parent directory paths to module file better + ([#1142](https://github.com/python-semantic-release/python-semantic-release/pull/1142), + [`c4056fc`](https://github.com/python-semantic-release/python-semantic-release/commit/c4056fc2e1fb3bddb78728793716ac6fb8522b1a)) + +The dynamic import originally would just replace "/" with "." to make the import module name more + pythonic, however this would be problematic in monorepos which would use + "../../misc/commit_parser.py" to locate the parser and so the resulting `sys.modules` entry would + have numerous periods (.) as a prefix. This removes that possibility. Still always an issue if the + imported module name matches an existing module but the likelihood is low. + +### Documentation + +- **github-actions**: Update PSR versions in github workflow examples + ([#1140](https://github.com/python-semantic-release/python-semantic-release/pull/1140), + [`9bdd626`](https://github.com/python-semantic-release/python-semantic-release/commit/9bdd626bf8f8359d35725cebe803931063260cac)) + + ## v9.16.0 (2025-01-12) ### Bug Fixes diff --git a/docs/automatic-releases/github-actions.rst b/docs/automatic-releases/github-actions.rst index eaae2711d..2fc8c8721 100644 --- a/docs/automatic-releases/github-actions.rst +++ b/docs/automatic-releases/github-actions.rst @@ -337,7 +337,7 @@ before the :ref:`version ` subcommand. .. code:: yaml - - uses: python-semantic-release/python-semantic-release@v9.12.0 + - uses: python-semantic-release/python-semantic-release@v9.16.1 with: root_options: "-vv --noop" @@ -576,7 +576,7 @@ before the :ref:`publish ` subcommand. .. code:: yaml - - uses: python-semantic-release/publish-action@v9.8.9 + - uses: python-semantic-release/publish-action@v9.16.1 with: root_options: "-vv --noop" @@ -684,7 +684,7 @@ to the GitHub Release Assets as well. - name: Action | Semantic Version Release id: release # Adjust tag with desired version if applicable. - uses: python-semantic-release/python-semantic-release@v9.12.0 + uses: python-semantic-release/python-semantic-release@v9.16.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} git_committer_name: "github-actions" @@ -695,7 +695,7 @@ to the GitHub Release Assets as well. if: steps.release.outputs.released == 'true' - name: Publish | Upload to GitHub Release Assets - uses: python-semantic-release/publish-action@v9.8.9 + uses: python-semantic-release/publish-action@v9.16.1 if: steps.release.outputs.released == 'true' with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -744,7 +744,7 @@ The equivalent GitHub Action configuration would be: - name: Action | Semantic Version Release # Adjust tag with desired version if applicable. - uses: python-semantic-release/python-semantic-release@v9.12.0 + uses: python-semantic-release/python-semantic-release@v9.16.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} force: patch @@ -772,13 +772,13 @@ Publish Action. .. code:: yaml - name: Release Project 1 - uses: python-semantic-release/python-semantic-release@v9.12.0 + uses: python-semantic-release/python-semantic-release@v9.16.1 with: directory: ./project1 github_token: ${{ secrets.GITHUB_TOKEN }} - name: Release Project 2 - uses: python-semantic-release/python-semantic-release@v9.12.0 + uses: python-semantic-release/python-semantic-release@v9.16.1 with: directory: ./project2 github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 91b9d3692..f7ab040c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "python-semantic-release" -version = "9.16.0" +version = "9.16.1" description = "Automatic Semantic Versioning for Python projects" requires-python = ">=3.8" license = { text = "MIT" } @@ -400,8 +400,6 @@ ignore_names = ["change_to_ex_proj_dir", "init_example_project"] logging_use_named_masks = true commit_parser = "angular" build_command = """ - python -m scripts.bump_version_in_docs - git add docs/* python -m pip install -e .[build] python -m build . """ diff --git a/scripts/bump_version_in_docs.py b/scripts/bump_version_in_docs.py index 30874d345..8167f0fad 100644 --- a/scripts/bump_version_in_docs.py +++ b/scripts/bump_version_in_docs.py @@ -3,35 +3,38 @@ from os import getenv from pathlib import Path -from re import compile as RegExp # noqa: N812 +from re import compile as regexp PROJ_DIR = Path(__file__).resolve().parent.parent DOCS_DIR = PROJ_DIR / "docs" -def update_github_actions_example(filepath: Path, new_version: str) -> None: - psr_regex = RegExp(r"(uses:.*python-semantic-release)@v\d+\.\d+\.\d+") +def update_github_actions_example(filepath: Path, release_tag: str) -> None: + psr_regex = regexp(r"(uses: python-semantic-release/python-semantic-release)@\S+$") + psr_publish_action_regex = regexp( + r"(uses: python-semantic-release/publish-action)@\S+$" + ) file_content_lines: list[str] = filepath.read_text().splitlines() - for regex in [psr_regex]: + for regex in [psr_regex, psr_publish_action_regex]: file_content_lines = list( map( - lambda line, regex=regex: regex.sub(r"\1@v" + new_version, line), # type: ignore[misc] + lambda line, regex=regex: regex.sub(r"\1@" + release_tag, line), # type: ignore[misc] file_content_lines, ) ) - print(f"Bumping version in {filepath} to", new_version) + print(f"Bumping version in {filepath} to", release_tag) filepath.write_text(str.join("\n", file_content_lines) + "\n") if __name__ == "__main__": - new_version = getenv("NEW_VERSION") + new_release_tag = getenv("NEW_RELEASE_TAG") - if not new_version: - print("NEW_VERSION environment variable is not set") + if not new_release_tag: + print("NEW_RELEASE_TAG environment variable is not set") exit(1) update_github_actions_example( - DOCS_DIR / "automatic-releases" / "github-actions.rst", new_version + DOCS_DIR / "automatic-releases" / "github-actions.rst", new_release_tag ) diff --git a/src/semantic_release/__init__.py b/src/semantic_release/__init__.py index d5a2e8cf6..c39aa0c23 100644 --- a/src/semantic_release/__init__.py +++ b/src/semantic_release/__init__.py @@ -24,7 +24,7 @@ tags_and_versions, ) -__version__ = "9.16.0" +__version__ = "9.16.1" __all__ = [ "CommitParser", diff --git a/src/semantic_release/helpers.py b/src/semantic_release/helpers.py index db82a97eb..83d700bfe 100644 --- a/src/semantic_release/helpers.py +++ b/src/semantic_release/helpers.py @@ -69,7 +69,6 @@ def dynamic_import(import_path: str) -> Any: Dynamically import an object from a conventionally formatted "module:attribute" string """ - log.debug("Trying to import %s", import_path) module_name, attr = import_path.split(":", maxsplit=1) # Check if the module is a file path, if it can be resolved and exists on disk then import as a file @@ -78,10 +77,11 @@ def dynamic_import(import_path: str) -> Any: module_path = ( module_filepath.stem if Path(module_name).is_absolute() - else str(Path(module_name).with_suffix("")).replace(os.sep, ".") + else str(Path(module_name).with_suffix("")).replace(os.sep, ".").lstrip(".") ) if module_path not in sys.modules: + log.debug("Loading '%s' from file '%s'", module_path, module_filepath) spec = importlib.util.spec_from_file_location( module_path, str(module_filepath) ) @@ -96,7 +96,9 @@ def dynamic_import(import_path: str) -> Any: # Otherwise, import as a module try: + log.debug("Importing module '%s'", module_name) module = importlib.import_module(module_name) + log.debug("Loading '%s' from module '%s'", attr, module_name) return getattr(module, attr) except TypeError as err: raise ImportError(