From 816660e1509b34ba387def3793e9bf9c7e343e8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:42:27 -0400 Subject: [PATCH 1/5] build(deps-dev): bump ruff from 0.3.4 to 0.3.5 (#880) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fe6da67f5..7e065d0b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ test = [ dev = [ "pre-commit ~= 3.5", "tox ~= 4.11", - "ruff == 0.3.4" + "ruff == 0.3.5" ] mypy = [ "mypy == 1.8.0", From 8a47db1a43c3fc9a8b7d03be3a8877e69acc7d3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:42:53 -0400 Subject: [PATCH 2/5] build(deps-dev): bump mypy from 1.8.0 to 1.9.0 (#879) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7e065d0b0..ceb0503fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ dev = [ "ruff == 0.3.5" ] mypy = [ - "mypy == 1.8.0", + "mypy == 1.9.0", "types-requests ~= 2.31.0" ] From 2c7b6ec85b6e3182463d7b695ee48e9669a25b3b Mon Sep 17 00:00:00 2001 From: codejedi365 Date: Sat, 6 Apr 2024 15:42:41 -0400 Subject: [PATCH 3/5] fix(gh-actions-output): fixed trailing newline to match GITHUB_OUTPUT format (#885) * test(gh-actions-output): fix unit tests to manage proper whitespace tests were adjusted for clarity and to replicate error detailed in #884. * fix(gh-actions-output): fixed trailing newline to match GITHUB_OUTPUT format Resolves: #884 --- semantic_release/cli/github_actions_output.py | 5 +- .../cli/test_github_actions_output.py | 77 +++++++++++-------- 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/semantic_release/cli/github_actions_output.py b/semantic_release/cli/github_actions_output.py index da4f770e4..c7ed8a740 100644 --- a/semantic_release/cli/github_actions_output.py +++ b/semantic_release/cli/github_actions_output.py @@ -62,7 +62,10 @@ def to_output_text(self) -> str: "version": str(self.version), "tag": self.tag, } - return "\n".join(f"{key}={value!s}" for key, value in outputs.items()) + + return str.join("", [ + f"{key}={value!s}\n" for key, value in outputs.items() + ]) def write_if_possible(self, filename: str | None = None) -> None: output_file = filename or os.getenv(self.OUTPUT_ENV_VAR) diff --git a/tests/unit/semantic_release/cli/test_github_actions_output.py b/tests/unit/semantic_release/cli/test_github_actions_output.py index 64d296e8c..9bac1b675 100644 --- a/tests/unit/semantic_release/cli/test_github_actions_output.py +++ b/tests/unit/semantic_release/cli/test_github_actions_output.py @@ -1,3 +1,8 @@ +from __future__ import annotations + +from textwrap import dedent +from typing import TYPE_CHECKING + import pytest from semantic_release import Version @@ -5,62 +10,68 @@ from tests.util import actions_output_to_dict +if TYPE_CHECKING: + from pathlib import Path + @pytest.mark.parametrize("released", (True, False)) -def test_version_github_actions_output_format(released): - version = Version.parse("1.2.3") - output = VersionGitHubActionsOutput() - - output.version = version - output.released = released - - text = output.to_output_text() - # fmt: off - assert ( - text == f"released={str(released).lower()}\n" - f"version={version!s}\n" - f"tag={version.as_tag()}" +def test_version_github_actions_output_format(released: bool): + version_str = "1.2.3" + expected_output = dedent( + f"""\ + released={'true' if released else 'false'} + version={version_str} + tag=v{version_str} + """ + ) + output = VersionGitHubActionsOutput( + released=released, + version=Version.parse(version_str), ) - # fmt: on + # Evaluate (expected -> actual) + assert expected_output == output.to_output_text() -def test_version_github_actions_output_fails_if_missing_output(): - version = Version.parse("1.2.3") - output = VersionGitHubActionsOutput() - output.version = version +def test_version_github_actions_output_fails_if_missing_output(): + output = VersionGitHubActionsOutput( + version=Version.parse("1.2.3"), + ) + # Execute with expected failure with pytest.raises(ValueError, match="required outputs were not set"): output.to_output_text() def test_version_github_actions_output_writes_to_github_output_if_available( - monkeypatch, tmp_path + monkeypatch: pytest.MonkeyPatch, tmp_path: Path ): mock_output_file = tmp_path / "action.out" - version = Version.parse("1.2.3") - output = VersionGitHubActionsOutput() - - output.version = version - output.released = True - + version_str = "1.2.3" monkeypatch.setenv("GITHUB_OUTPUT", str(mock_output_file.resolve())) + output = VersionGitHubActionsOutput( + version=Version.parse(version_str), + released=True, + ) + output.write_if_possible() action_outputs = actions_output_to_dict( mock_output_file.read_text(encoding="utf-8") ) - assert action_outputs["version"] == str(version) - assert action_outputs["released"] == "true" + # Evaluate (expected -> actual) + assert version_str == action_outputs["version"] + assert str(True).lower() == action_outputs["released"] -def test_version_github_actions_output_no_error_if_not_in_gha(monkeypatch): - version = Version.parse("1.2.3") - output = VersionGitHubActionsOutput() - - output.version = version - output.released = True +def test_version_github_actions_output_no_error_if_not_in_gha( + monkeypatch: pytest.MonkeyPatch, +): + output = VersionGitHubActionsOutput( + version=Version.parse("1.2.3"), + released=True, + ) monkeypatch.delenv("GITHUB_OUTPUT", raising=False) output.write_if_possible() From b9ecd8461c36c4f904b78dc83d9ca2b10b6d89f5 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 6 Apr 2024 19:48:10 +0000 Subject: [PATCH 4/5] style: beautify 2c7b6ec85b6e3182463d7b695ee48e9669a25b3b --- semantic_release/cli/github_actions_output.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/semantic_release/cli/github_actions_output.py b/semantic_release/cli/github_actions_output.py index c7ed8a740..427a8bf2c 100644 --- a/semantic_release/cli/github_actions_output.py +++ b/semantic_release/cli/github_actions_output.py @@ -63,9 +63,7 @@ def to_output_text(self) -> str: "tag": self.tag, } - return str.join("", [ - f"{key}={value!s}\n" for key, value in outputs.items() - ]) + return str.join("", [f"{key}={value!s}\n" for key, value in outputs.items()]) def write_if_possible(self, filename: str | None = None) -> None: output_file = filename or os.getenv(self.OUTPUT_ENV_VAR) From 074cff45a89828d547109f8296e8bcbcbe5f427d Mon Sep 17 00:00:00 2001 From: semantic-release Date: Sat, 6 Apr 2024 19:50:26 +0000 Subject: [PATCH 5/5] 9.4.1 Automatically generated by python-semantic-release --- CHANGELOG.md | 25 +++++++++++++++++++++++++ pyproject.toml | 2 +- semantic_release/__init__.py | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9180c34df..24bb69dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ +## v9.4.1 (2024-04-06) + +### Build + +* build(deps-dev): bump mypy from 1.8.0 to 1.9.0 (#879) ([`8a47db1`](https://github.com/python-semantic-release/python-semantic-release/commit/8a47db1a43c3fc9a8b7d03be3a8877e69acc7d3c)) + +* build(deps-dev): bump ruff from 0.3.4 to 0.3.5 (#880) ([`816660e`](https://github.com/python-semantic-release/python-semantic-release/commit/816660e1509b34ba387def3793e9bf9c7e343e8c)) + +### Fix + +* fix(gh-actions-output): fixed trailing newline to match GITHUB_OUTPUT format (#885) + +* test(gh-actions-output): fix unit tests to manage proper whitespace + + tests were adjusted for clarity and to replicate error detailed in #884. + +* fix(gh-actions-output): fixed trailing newline to match GITHUB_OUTPUT format + + Resolves: #884 ([`2c7b6ec`](https://github.com/python-semantic-release/python-semantic-release/commit/2c7b6ec85b6e3182463d7b695ee48e9669a25b3b)) + +### Style + +* style: beautify 2c7b6ec85b6e3182463d7b695ee48e9669a25b3b ([`b9ecd84`](https://github.com/python-semantic-release/python-semantic-release/commit/b9ecd8461c36c4f904b78dc83d9ca2b10b6d89f5)) + + ## v9.4.0 (2024-03-31) ### Build diff --git a/pyproject.toml b/pyproject.toml index ceb0503fa..f8609b302 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" [project] name = "python-semantic-release" -version = "9.4.0" +version = "9.4.1" description = "Automatic Semantic Versioning for Python projects" requires-python = ">=3.8" license = { text = "MIT" } diff --git a/semantic_release/__init__.py b/semantic_release/__init__.py index c3f947e38..159ed0e5c 100644 --- a/semantic_release/__init__.py +++ b/semantic_release/__init__.py @@ -24,7 +24,7 @@ tags_and_versions, ) -__version__ = "9.4.0" +__version__ = "9.4.1" def setup_hook(argv: list[str]) -> None: