python-semantic-release 9.5.0__tar.gz → 9.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. {python_semantic_release-9.5.0/python_semantic_release.egg-info → python_semantic_release-9.6.0}/PKG-INFO +1 -1
  2. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/changelog_templates.rst +43 -5
  3. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/commands.rst +85 -14
  4. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/multibranch_releases.rst +1 -1
  5. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/pyproject.toml +1 -1
  6. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0/python_semantic_release.egg-info}/PKG-INFO +1 -1
  7. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/python_semantic_release.egg-info/SOURCES.txt +3 -2
  8. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/__init__.py +1 -1
  9. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/changelog/context.py +3 -1
  10. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/changelog.py +2 -1
  11. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/publish.py +8 -0
  12. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/version.py +79 -40
  13. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/config.py +94 -19
  14. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/_base.py +13 -4
  15. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/angular.py +7 -2
  16. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/emoji.py +5 -0
  17. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/scipy.py +12 -13
  18. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/tag.py +5 -0
  19. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/errors.py +22 -1
  20. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/__init__.py +10 -1
  21. python_semantic_release-9.6.0/semantic_release/hvcs/_base.py +83 -0
  22. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/bitbucket.py +87 -140
  23. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/gitea.py +61 -71
  24. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/github.py +120 -156
  25. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/gitlab.py +34 -76
  26. python_semantic_release-9.6.0/semantic_release/hvcs/remote_hvcs_base.py +193 -0
  27. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/test_version.py +79 -53
  28. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/conftest.py +12 -0
  29. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/const.py +1 -30
  30. python_semantic_release-9.6.0/tests/fixtures/commit_parsers.py +46 -0
  31. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/example_project.py +54 -10
  32. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/git_repo.py +4 -2
  33. python_semantic_release-9.6.0/tests/fixtures/scipy.py +437 -0
  34. python_semantic_release-9.6.0/tests/unit/semantic_release/changelog/test_changelog_context.py +337 -0
  35. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/changelog/test_default_changelog.py +16 -16
  36. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/cli/test_config.py +99 -5
  37. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/cli/test_util.py +12 -7
  38. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/commit_parser/test_angular.py +53 -37
  39. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/commit_parser/test_emoji.py +23 -23
  40. python_semantic_release-9.6.0/tests/unit/semantic_release/commit_parser/test_parsed_commit.py +27 -0
  41. python_semantic_release-9.6.0/tests/unit/semantic_release/commit_parser/test_scipy.py +126 -0
  42. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/commit_parser/test_tag.py +25 -20
  43. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test__base.py +18 -3
  44. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test_bitbucket.py +76 -76
  45. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test_gitea.py +21 -10
  46. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test_github.py +22 -11
  47. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/util.py +27 -3
  48. python_semantic_release-9.5.0/semantic_release/hvcs/_base.py +0 -160
  49. python_semantic_release-9.5.0/tests/fixtures/commit_parsers.py +0 -39
  50. python_semantic_release-9.5.0/tests/fixtures/scipy.py +0 -163
  51. python_semantic_release-9.5.0/tests/unit/semantic_release/commit_parser/helper.py +0 -5
  52. python_semantic_release-9.5.0/tests/unit/semantic_release/commit_parser/test_scipy.py +0 -13
  53. python_semantic_release-9.5.0/tests/unit/semantic_release/commit_parser/test_token.py +0 -22
  54. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/AUTHORS.rst +0 -0
  55. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/LICENSE +0 -0
  56. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/MANIFEST.in +0 -0
  57. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/README.rst +0 -0
  58. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/Makefile +0 -0
  59. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/algorithm.rst +0 -0
  60. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/automatic-releases/cronjobs.rst +0 -0
  61. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/automatic-releases/github-actions.rst +0 -0
  62. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/automatic-releases/index.rst +0 -0
  63. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/automatic-releases/travis.rst +0 -0
  64. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/commit-parsing.rst +0 -0
  65. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/conf.py +0 -0
  66. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/configuration.rst +0 -0
  67. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/contributing.rst +0 -0
  68. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/contributors.rst +0 -0
  69. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/github-action.rst +0 -0
  70. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/index.rst +0 -0
  71. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/make.bat +0 -0
  72. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/migrating_from_v7.rst +0 -0
  73. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/strict_mode.rst +0 -0
  74. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/docs/troubleshooting.rst +0 -0
  75. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/python_semantic_release.egg-info/dependency_links.txt +0 -0
  76. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/python_semantic_release.egg-info/entry_points.txt +0 -0
  77. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/python_semantic_release.egg-info/requires.txt +0 -0
  78. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/python_semantic_release.egg-info/top_level.txt +0 -0
  79. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/__main__.py +0 -0
  80. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/changelog/__init__.py +0 -0
  81. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/changelog/release_history.py +0 -0
  82. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/changelog/template.py +0 -0
  83. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/__init__.py +0 -0
  84. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/__init__.py +0 -0
  85. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/cli_context.py +0 -0
  86. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/generate_config.py +0 -0
  87. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/commands/main.py +0 -0
  88. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/common.py +0 -0
  89. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/const.py +0 -0
  90. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/github_actions_output.py +0 -0
  91. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/masking_filter.py +0 -0
  92. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/cli/util.py +0 -0
  93. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/__init__.py +0 -0
  94. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/token.py +0 -0
  95. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/commit_parser/util.py +0 -0
  96. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/const.py +0 -0
  97. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/data/templates/CHANGELOG.md.j2 +0 -0
  98. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/data/templates/release_notes.md.j2 +0 -0
  99. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/enums.py +0 -0
  100. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/helpers.py +0 -0
  101. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/token_auth.py +0 -0
  102. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/hvcs/util.py +0 -0
  103. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/version/__init__.py +0 -0
  104. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/version/algorithm.py +0 -0
  105. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/version/declaration.py +0 -0
  106. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/version/translator.py +0 -0
  107. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/semantic_release/version/version.py +0 -0
  108. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/setup.cfg +0 -0
  109. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/__init__.py +0 -0
  110. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/__init__.py +0 -0
  111. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/conftest.py +0 -0
  112. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/test_changelog.py +0 -0
  113. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/test_generate_config.py +0 -0
  114. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/test_help.py +0 -0
  115. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/test_main.py +0 -0
  116. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/command_line/test_publish.py +0 -0
  117. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/__init__.py +0 -0
  118. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/__init__.py +0 -0
  119. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/git_flow/__init__.py +0 -0
  120. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/git_flow/repo_w_2_release_channels.py +0 -0
  121. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/git_flow/repo_w_3_release_channels.py +0 -0
  122. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/github_flow/__init__.py +0 -0
  123. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/github_flow/repo_w_release_channels.py +0 -0
  124. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/trunk_based_dev/__init__.py +0 -0
  125. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/trunk_based_dev/repo_w_no_tags.py +0 -0
  126. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/trunk_based_dev/repo_w_prereleases.py +0 -0
  127. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/fixtures/repos/trunk_based_dev/repo_w_tags.py +0 -0
  128. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/scenario/__init__.py +0 -0
  129. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/scenario/test_next_version.py +0 -0
  130. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/scenario/test_release_history.py +0 -0
  131. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/scenario/test_template_render.py +0 -0
  132. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/__init__.py +0 -0
  133. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/__init__.py +0 -0
  134. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/changelog/__init__.py +0 -0
  135. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/changelog/test_release_notes.py +0 -0
  136. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/changelog/test_template.py +0 -0
  137. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/cli/__init__.py +0 -0
  138. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/cli/test_github_actions_output.py +0 -0
  139. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/cli/test_masking_filter.py +0 -0
  140. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/cli/test_version.py +0 -0
  141. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/commit_parser/__init__.py +0 -0
  142. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/commit_parser/test_util.py +0 -0
  143. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/__init__.py +0 -0
  144. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test_gitlab.py +0 -0
  145. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test_token_auth.py +0 -0
  146. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/hvcs/test_util.py +0 -0
  147. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/test_helpers.py +0 -0
  148. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/version/__init__.py +0 -0
  149. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/version/test_algorithm.py +0 -0
  150. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/version/test_declaration.py +0 -0
  151. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/version/test_translator.py +0 -0
  152. {python_semantic_release-9.5.0 → python_semantic_release-9.6.0}/tests/unit/semantic_release/version/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-semantic-release
3
- Version: 9.5.0
3
+ Version: 9.6.0
4
4
  Summary: Automatic Semantic Versioning for Python projects
5
5
  Author-email: Rolf Erik Lekang <me@rolflekang.com>
6
6
  License: MIT
@@ -144,8 +144,8 @@ project.
144
144
 
145
145
  .. _changelog-templates-template-rendering-template-context:
146
146
 
147
- Template Context:
148
- ^^^^^^^^^^^^^^^^^
147
+ Template Context
148
+ ^^^^^^^^^^^^^^^^
149
149
 
150
150
  Alongside the rendering of a directory tree, Python Semantic Release makes information
151
151
  about the history of the project available within the templating environment in order
@@ -156,19 +156,57 @@ Python terms, ``context`` is a `dataclass`_ with the following attributes:
156
156
 
157
157
  * ``repo_name: str``: the name of the current repository parsed from the Git url.
158
158
  * ``repo_owner: str``: the owner of the current repository parsed from the Git url.
159
+ * ``hvcs_type: str``: the name of the VCS server type currently configured.
159
160
  * ``history: ReleaseHistory``: a :py:class:`semantic_release.changelog.ReleaseHistory` instance.
160
161
  (See :ref:`changelog-templates-template-rendering-template-context-release-history`)
161
162
  * ``filters: Tuple[Callable[..., Any], ...]``: a tuple of filters for the template environment.
162
163
  These are added to the environment's ``filters``, and therefore there should be no need to
163
164
  access these from the ``context`` object inside the template.
164
165
 
165
- Currently, two filters are defined:
166
+ The filters provided vary based on the VCS configured and available features:
167
+
168
+ * ``create_server_url: Callable[[str, str | None, str | None, str | None], str]``: when given
169
+ a path, prepend the configured vcs server host and url scheme. Optionally you can provide,
170
+ a auth string, a query string or a url fragment to be normalized into the resulting url.
171
+ Parameter order is as described above respectively.
172
+
173
+ * ``create_repo_url: Callable[[str, str | None, str | None], str]``: when given a repository
174
+ path, prepend the configured vcs server host, and repo namespace. Optionally you can provide,
175
+ an additional query string and/or a url fragment to also put in the url. Parameter order is
176
+ as described above respectively. This is similar to ``create_server_url`` but includes the repo
177
+ namespace and owner automatically.
166
178
 
167
- * ``pull_request_url: Callable[[str], str]``: given a pull request number, return a URL
168
- to the pull request in the remote.
169
179
  * ``commit_hash_url: Callable[[str], str]``: given a commit hash, return a URL to the
170
180
  commit in the remote.
171
181
 
182
+ * ``compare_url: Callable[[str, str], str]``: given a starting git reference and a ending git
183
+ reference create a comparison url between the two references that can be opened on the remote
184
+
185
+ * ``issue_url: Callable[[str | int], str]``: given an issue number, return a URL to the issue
186
+ on the remote vcs.
187
+
188
+ * ``merge_request_url: Callable[[str | int], str]``: given a merge request number, return a URL
189
+ to the merge request in the remote. This is an alias to the ``pull_request_url`` but only
190
+ available for the VCS that uses the merge request terminology.
191
+
192
+ * ``pull_request_url: Callable[[str | int], str]``: given a pull request number, return a URL
193
+ to the pull request in the remote. For remote vcs' that use merge request terminology, this
194
+ filter is an alias to the ``merge_request_url`` filter function.
195
+
196
+ Availability of the documented filters can be found in the table below:
197
+
198
+ ====================== ========= ===== ====== ======
199
+ **filter - hvcs_type** bitbucket gitea github gitlab
200
+ ====================== ========= ===== ====== ======
201
+ create_server_url ✅ ✅ ✅ ✅
202
+ create_repo_url ✅ ✅ ✅ ✅
203
+ commit_hash_url ✅ ✅ ✅ ✅
204
+ compare_url ✅ ❌ ✅ ✅
205
+ issue_url ❌ ✅ ✅ ✅
206
+ merge_request_url ❌ ❌ ❌ ✅
207
+ pull_request_url ✅ ✅ ✅ ✅
208
+ ====================== ========= ===== ====== ======
209
+
172
210
  .. seealso::
173
211
  * `Filters <https://jinja.palletsprojects.com/en/3.1.x/templates/#filters>`_
174
212
 
@@ -173,39 +173,110 @@ number (``1.0.0``).
173
173
 
174
174
  .. _cmd-version-option-force-level:
175
175
 
176
- ``--major/--minor/--patch``
177
- ***************************
176
+ ``--major/--minor/--patch/--prerelease``
177
+ ****************************************
178
178
 
179
- Force the next version to increment the major, minor or patch digit, respectively.
180
- These flags are optional but mutually exclusive, so only one may be supplied, or none at all.
181
- Using these flags overrides the usual calculation for the next version; this can be useful, say,
182
- when a project wants to release its initial 1.0.0 version.
179
+ Force the next version to increment the major, minor or patch digits, or the prerelease revision,
180
+ respectively. These flags are optional but mutually exclusive, so only one may be supplied, or
181
+ none at all. Using these flags overrides the usual calculation for the next version; this can
182
+ be useful, say, when a project wants to release its initial 1.0.0 version.
183
183
 
184
184
  .. warning::
185
- Using these flags will override the value of prerelease, **regardless of your configuration or the
186
- current version**. To produce a prerelease with the appropriate digit incremented you should also
187
- supply the :ref:`cmd-version-option-prerelease` flag. If you do not, using these flags will force
185
+
186
+ Using these flags will override the configured value of ``prerelease`` (configured
187
+ in your :ref:`Release Group<multibranch-releases-configuring>`),
188
+ **regardless of your configuration or the current version**.
189
+
190
+ To produce a prerelease with the appropriate digit incremented you should also
191
+ supply the :ref:`cmd-version-option-as-prerelease` flag. If you do not, using these flags will force
188
192
  a full (non-prerelease) version to be created.
189
193
 
194
+ For example, suppose your project's current version is ``0.2.1-rc.1``. The following
195
+ shows how these options can be combined with ``--as-prerelease`` to force different
196
+ versions:
197
+
198
+ .. code-block:: bash
199
+
200
+ semantic-release version --prerelease --print
201
+ # 0.2.1-rc.2
202
+
203
+ semantic-release version --patch --print
204
+ # 0.2.2
205
+
206
+ semantic-release version --minor --print
207
+ # 0.3.0
208
+
209
+ semantic-release version --major --print
210
+ # 1.0.0
211
+
212
+ semantic-release version --minor --as-prerelease --print
213
+ # 0.3.0-rc.1
214
+
215
+ semantic-release version --prerelease --as-prerelease --print
216
+ # 0.2.1-rc.2
217
+
190
218
  These options are forceful overrides, but there is no action required for subsequent releases
191
219
  performed using the usual calculation algorithm.
192
220
 
221
+ Supplying ``--prerelease`` will cause Python Semantic Release to scan your project history
222
+ for any previous prereleases with the same major, minor and patch versions as the latest
223
+ version and the same :ref:`prerelease token<cmd-version-option-prerelease-token>` as the
224
+ one passed by command-line or configuration. If one is not found, ``--prerelease`` will
225
+ produce the next version according to the following format:
226
+
227
+ .. code-block:: python
228
+
229
+ f"{latest_version.major}.{latest_version.minor}.{latest_version.patch}-{prerelease_token}.1"
230
+
231
+ However, if Python Semantic Release identifies a previous *prerelease* version with the same
232
+ major, minor and patch digits as the latest version, *and* the same prerelease token as the
233
+ one supplied by command-line or configuration, then Python Semantic Release will increment
234
+ the revision found on that previous prerelease version in its new version.
235
+
236
+ For example, if ``"0.2.1-rc.1"`` and already exists as a previous version, and the latest version
237
+ is ``"0.2.1"``, invoking the following command will produce ``"0.2.1-rc.2"``:
238
+
239
+ .. code-block:: bash
240
+
241
+ semantic-release version --prerelease --prerelease-token "rc" --print
242
+
243
+ .. warning::
244
+
245
+ This is true irrespective of the branch from which ``"0.2.1-rc.1"`` was released from.
246
+ The check for previous prereleases "leading up to" this normal version is intended to
247
+ help prevent collisions in git tags to an extent, but isn't foolproof. As the example
248
+ shows it is possible to release a prerelease for a normal version that's already been
249
+ released when using this flag, which would in turn be ignored by tools selecting
250
+ versions by `SemVer precedence rules`_.
251
+
252
+
253
+ .. _SemVer precedence rules: https://semver.org/#spec-item-11
254
+
255
+
193
256
  .. seealso::
194
257
  - :ref:`configuration`
195
258
  - :ref:`config-branches`
196
259
 
197
- .. _cmd-version-option-prerelease:
260
+ .. _cmd-version-option-as-prerelease:
198
261
 
199
- ``--prerelease``
200
- ****************
262
+ ``--as-prerelease``
263
+ *******************
201
264
 
202
- Force the next version to be a prerelease. As with :ref:`cmd-version-option-force-level`, this option
265
+ After performing the normal calculation of the next version, convert the resulting next version
266
+ to a prerelease before applying it. As with :ref:`cmd-version-option-force-level`, this option
203
267
  is a forceful override, but no action is required to resume calculating versions as normal on the
204
- subsequent releases.
268
+ subsequent releases. The main distinction between ``--prerelease`` and ``--as-prerelease`` is that
269
+ the latter will not *force* a new version if one would not have been released without supplying
270
+ the flag.
271
+
272
+ This can be useful when making a single prerelease on a branch that would typically release
273
+ normal versions.
205
274
 
206
275
  If not specified in :ref:`cmd-version-option-prerelease-token`, the prerelease token is idenitified using the
207
276
  :ref:`Multibranch Release Configuration <multibranch-releases-configuring>`
208
277
 
278
+ See the examples alongside :ref:`cmd-version-option-force-level` for how to use this flag.
279
+
209
280
  .. _cmd-version-option-prerelease-token:
210
281
 
211
282
  ``--prerelease-token [VALUE]``
@@ -163,5 +163,5 @@ This would lead to versions such as ``1.1.1+main.20221127`` or ``2.0.0-rc.4+2.x.
163
163
 
164
164
  .. note::
165
165
  Remember that is always possible to override the release rules configured by using
166
- the :ref:`cmd-version-option-force-level` and :ref:`cmd-version-option-prerelease`
166
+ the :ref:`cmd-version-option-force-level` and :ref:`cmd-version-option-as-prerelease`
167
167
  flags.
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "python-semantic-release"
9
- version = "9.5.0"
9
+ version = "9.6.0"
10
10
  description = "Automatic Semantic Versioning for Python projects"
11
11
  requires-python = ">=3.8"
12
12
  license = { text = "MIT" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-semantic-release
3
- Version: 9.5.0
3
+ Version: 9.6.0
4
4
  Summary: Automatic Semantic Versioning for Python projects
5
5
  Author-email: Rolf Erik Lekang <me@rolflekang.com>
6
6
  License: MIT
@@ -71,6 +71,7 @@ semantic_release/hvcs/bitbucket.py
71
71
  semantic_release/hvcs/gitea.py
72
72
  semantic_release/hvcs/github.py
73
73
  semantic_release/hvcs/gitlab.py
74
+ semantic_release/hvcs/remote_hvcs_base.py
74
75
  semantic_release/hvcs/token_auth.py
75
76
  semantic_release/hvcs/util.py
76
77
  semantic_release/version/__init__.py
@@ -113,6 +114,7 @@ tests/unit/__init__.py
113
114
  tests/unit/semantic_release/__init__.py
114
115
  tests/unit/semantic_release/test_helpers.py
115
116
  tests/unit/semantic_release/changelog/__init__.py
117
+ tests/unit/semantic_release/changelog/test_changelog_context.py
116
118
  tests/unit/semantic_release/changelog/test_default_changelog.py
117
119
  tests/unit/semantic_release/changelog/test_release_notes.py
118
120
  tests/unit/semantic_release/changelog/test_template.py
@@ -123,12 +125,11 @@ tests/unit/semantic_release/cli/test_masking_filter.py
123
125
  tests/unit/semantic_release/cli/test_util.py
124
126
  tests/unit/semantic_release/cli/test_version.py
125
127
  tests/unit/semantic_release/commit_parser/__init__.py
126
- tests/unit/semantic_release/commit_parser/helper.py
127
128
  tests/unit/semantic_release/commit_parser/test_angular.py
128
129
  tests/unit/semantic_release/commit_parser/test_emoji.py
130
+ tests/unit/semantic_release/commit_parser/test_parsed_commit.py
129
131
  tests/unit/semantic_release/commit_parser/test_scipy.py
130
132
  tests/unit/semantic_release/commit_parser/test_tag.py
131
- tests/unit/semantic_release/commit_parser/test_token.py
132
133
  tests/unit/semantic_release/commit_parser/test_util.py
133
134
  tests/unit/semantic_release/hvcs/__init__.py
134
135
  tests/unit/semantic_release/hvcs/test__base.py
@@ -24,7 +24,7 @@ from semantic_release.version import (
24
24
  tags_and_versions,
25
25
  )
26
26
 
27
- __version__ = "9.5.0"
27
+ __version__ = "9.6.0"
28
28
 
29
29
 
30
30
  def setup_hook(argv: list[str]) -> None:
@@ -14,6 +14,7 @@ if TYPE_CHECKING:
14
14
  class ChangelogContext:
15
15
  repo_name: str
16
16
  repo_owner: str
17
+ hvcs_type: str
17
18
  history: ReleaseHistory
18
19
  filters: tuple[Callable[..., Any], ...] = ()
19
20
 
@@ -31,5 +32,6 @@ def make_changelog_context(
31
32
  repo_name=hvcs_client.repo_name,
32
33
  repo_owner=hvcs_client.owner,
33
34
  history=release_history,
34
- filters=(hvcs_client.pull_request_url, hvcs_client.commit_hash_url),
35
+ hvcs_type=hvcs_client.__class__.__name__.lower(),
36
+ filters=(*hvcs_client.get_changelog_context_filters(),),
35
37
  )
@@ -14,6 +14,7 @@ from semantic_release.cli.common import (
14
14
  render_release_notes,
15
15
  )
16
16
  from semantic_release.cli.util import noop_report
17
+ from semantic_release.hvcs.remote_hvcs_base import RemoteHvcsBase
17
18
 
18
19
  if TYPE_CHECKING:
19
20
  from semantic_release.cli.commands.cli_context import CliContextObj
@@ -79,7 +80,7 @@ def changelog(cli_ctx: CliContextObj, release_tag: str | None = None) -> None:
79
80
  else:
80
81
  recursive_render(template_dir, environment=env, _root_dir=repo.working_dir)
81
82
 
82
- if release_tag:
83
+ if release_tag and isinstance(hvcs_client, RemoteHvcsBase):
83
84
  if runtime.global_cli_options.noop:
84
85
  noop_report(
85
86
  f"would have posted changelog to the release for tag {release_tag}"
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING
6
6
  import click
7
7
 
8
8
  from semantic_release.cli.util import noop_report
9
+ from semantic_release.hvcs.remote_hvcs_base import RemoteHvcsBase
9
10
  from semantic_release.version import tags_and_versions
10
11
 
11
12
  if TYPE_CHECKING:
@@ -45,6 +46,13 @@ def publish(cli_ctx: CliContextObj, tag: str = "latest") -> None:
45
46
  f"No tags found with format {translator.tag_format!r}, couldn't "
46
47
  "identify latest version"
47
48
  )
49
+
50
+ if not isinstance(hvcs_client, RemoteHvcsBase):
51
+ log.info(
52
+ "Remote does not support artifact upload. Exiting with no action taken..."
53
+ )
54
+ ctx.exit(0)
55
+
48
56
  if runtime.global_cli_options.noop:
49
57
  noop_report(
50
58
  "would have uploaded files matching any of the globs "
@@ -25,6 +25,7 @@ from semantic_release.cli.util import indented, noop_report, rprint
25
25
  from semantic_release.const import DEFAULT_SHELL, DEFAULT_VERSION
26
26
  from semantic_release.enums import LevelBump
27
27
  from semantic_release.errors import UnexpectedResponse
28
+ from semantic_release.hvcs.remote_hvcs_base import RemoteHvcsBase
28
29
  from semantic_release.version import Version, next_version, tags_and_versions
29
30
 
30
31
  log = logging.getLogger(__name__)
@@ -41,7 +42,7 @@ if TYPE_CHECKING: # pragma: no cover
41
42
 
42
43
 
43
44
  def is_forced_prerelease(
44
- force_prerelease: bool, force_level: str | None, prerelease: bool
45
+ as_prerelease: bool, forced_level_bump: LevelBump | None, prerelease: bool
45
46
  ) -> bool:
46
47
  """
47
48
  Determine if this release is forced to have prerelease on/off.
@@ -50,8 +51,17 @@ def is_forced_prerelease(
50
51
  it's False.
51
52
  Otherwise (``force_level is None``) use the value of ``prerelease``
52
53
  """
53
- log.debug(", ".join(f"{k} = {v}" for k, v in locals().items()))
54
- return force_prerelease or ((force_level is None) and prerelease)
54
+ local_vars = list(locals().items())
55
+ log.debug(
56
+ "%s: %s",
57
+ is_forced_prerelease.__name__,
58
+ ", ".join(f"{k} = {v}" for k, v in local_vars),
59
+ )
60
+ return (
61
+ as_prerelease
62
+ or forced_level_bump is LevelBump.PRERELEASE_REVISION
63
+ or ((forced_level_bump is None) and prerelease)
64
+ )
55
65
 
56
66
 
57
67
  def last_released(
@@ -62,16 +72,41 @@ def last_released(
62
72
 
63
73
 
64
74
  def version_from_forced_level(
65
- repo: Repo, level_bump: LevelBump, translator: VersionTranslator
75
+ repo: Repo, forced_level_bump: LevelBump, translator: VersionTranslator
66
76
  ) -> Version:
67
77
  ts_and_vs = tags_and_versions(repo.tags, translator)
68
78
 
69
79
  # If we have no tags, return the default version
70
80
  if not ts_and_vs:
71
- return Version.parse(DEFAULT_VERSION).bump(level_bump)
81
+ return Version.parse(DEFAULT_VERSION).bump(forced_level_bump)
72
82
 
73
83
  _, latest_version = ts_and_vs[0]
74
- return latest_version.bump(level_bump)
84
+ if forced_level_bump is not LevelBump.PRERELEASE_REVISION:
85
+ return latest_version.bump(forced_level_bump)
86
+
87
+ # We need to find the latest version with the prerelease token
88
+ # we're looking for, and return that version + an increment to
89
+ # the prerelease revision.
90
+
91
+ # NOTE this can probably be cleaned up.
92
+ # ts_and_vs are in order, so check if we're looking at prereleases
93
+ # for the same (major, minor, patch) as the latest version.
94
+ # If we are, we can increment the revision and we're done. If
95
+ # we don't find a prerelease targeting this version with the same
96
+ # token as the one we're looking to prerelease, we can use revision 1.
97
+ for _, version in ts_and_vs:
98
+ if not (
99
+ version.major == latest_version.major
100
+ and version.minor == latest_version.minor
101
+ and version.patch == latest_version.patch
102
+ ):
103
+ break
104
+ if (
105
+ version.is_prerelease
106
+ and version.prerelease_token == translator.prerelease_token
107
+ ):
108
+ return version.bump(LevelBump.PRERELEASE_REVISION)
109
+ return latest_version.to_prerelease(token=translator.prerelease_token, revision=1)
75
110
 
76
111
 
77
112
  def apply_version_to_source_files(
@@ -145,10 +180,10 @@ def shell(cmd: str, *, check: bool = True) -> subprocess.CompletedProcess:
145
180
  help="Print the last released version tag and exit",
146
181
  )
147
182
  @click.option(
148
- "--prerelease",
149
- "force_prerelease",
183
+ "--as-prerelease",
184
+ "as_prerelease",
150
185
  is_flag=True,
151
- help="Force the next version to be a prerelease",
186
+ help="Ensure the next version to be released is a prerelease version",
152
187
  )
153
188
  @click.option(
154
189
  "--prerelease-token",
@@ -160,19 +195,25 @@ def shell(cmd: str, *, check: bool = True) -> subprocess.CompletedProcess:
160
195
  "--major",
161
196
  "force_level",
162
197
  flag_value="major",
163
- help="force the next version to be a major release",
198
+ help="Force the next version to be a major release",
164
199
  )
165
200
  @click.option(
166
201
  "--minor",
167
202
  "force_level",
168
203
  flag_value="minor",
169
- help="force the next version to be a minor release",
204
+ help="Force the next version to be a minor release",
170
205
  )
171
206
  @click.option(
172
207
  "--patch",
173
208
  "force_level",
174
209
  flag_value="patch",
175
- help="force the next version to be a patch release",
210
+ help="Force the next version to be a patch release",
211
+ )
212
+ @click.option(
213
+ "--prerelease",
214
+ "force_level",
215
+ flag_value="prerelease_revision",
216
+ help="Force the next version to be a prerelease",
176
217
  )
177
218
  @click.option(
178
219
  "--commit/--no-commit",
@@ -224,7 +265,7 @@ def version( # noqa: C901
224
265
  print_only_tag: bool = False,
225
266
  print_last_released: bool = False,
226
267
  print_last_released_tag: bool = False,
227
- force_prerelease: bool = False,
268
+ as_prerelease: bool = False,
228
269
  prerelease_token: str | None = None,
229
270
  force_level: str | None = None,
230
271
  commit_changes: bool = True,
@@ -271,9 +312,10 @@ def version( # noqa: C901
271
312
  ctx.exit(0)
272
313
 
273
314
  parser = runtime.commit_parser
315
+ forced_level_bump = None if not force_level else LevelBump.from_string(force_level)
274
316
  prerelease = is_forced_prerelease(
275
- force_prerelease=force_prerelease,
276
- force_level=force_level,
317
+ as_prerelease=as_prerelease,
318
+ forced_level_bump=forced_level_bump,
277
319
  prerelease=runtime.prerelease,
278
320
  )
279
321
  hvcs_client = runtime.hvcs_client
@@ -306,23 +348,19 @@ def version( # noqa: C901
306
348
  log.info("No vcs release will be created because pushing changes is disabled")
307
349
  make_vcs_release &= push_changes
308
350
 
309
- if force_prerelease:
310
- log.warning("Forcing prerelease due to '--prerelease' command-line flag")
311
- elif force_level:
351
+ if forced_level_bump:
312
352
  log.warning(
313
- "Forcing prerelease=False due to '--%s' command-line flag and no "
314
- "'--prerelease' flag",
353
+ "Forcing a '%s' release due to '--%s' command-line flag",
315
354
  force_level,
316
- )
317
-
318
- if force_level:
319
- level_bump = LevelBump.from_string(force_level)
320
- log.warning(
321
- "Forcing a %s level bump due to '--force' command-line option", force_level
355
+ (
356
+ force_level
357
+ if forced_level_bump is not LevelBump.PRERELEASE_REVISION
358
+ else "prerelease"
359
+ ),
322
360
  )
323
361
 
324
362
  new_version = version_from_forced_level(
325
- repo=repo, level_bump=level_bump, translator=translator
363
+ repo=repo, forced_level_bump=forced_level_bump, translator=translator
326
364
  )
327
365
 
328
366
  # We only turn the forced version into a prerelease if the user has specified
@@ -347,6 +385,17 @@ def version( # noqa: C901
347
385
  if build_metadata:
348
386
  new_version.build_metadata = build_metadata
349
387
 
388
+ if as_prerelease:
389
+ before_conversion, new_version = (
390
+ new_version,
391
+ new_version.to_prerelease(token=translator.prerelease_token),
392
+ )
393
+ log.info(
394
+ "Converting %s to %s due to '--as-prerelease' command-line option",
395
+ before_conversion,
396
+ new_version,
397
+ )
398
+
350
399
  gha_output.released = False
351
400
  gha_output.version = new_version
352
401
  ctx.call_on_close(gha_output.write_if_possible)
@@ -601,7 +650,7 @@ def version( # noqa: C901
601
650
 
602
651
  gha_output.released = True
603
652
 
604
- if make_vcs_release:
653
+ if make_vcs_release and isinstance(hvcs_client, RemoteHvcsBase):
605
654
  if opts.noop:
606
655
  noop_report(
607
656
  f"would have created a release for the tag {new_version.as_tag()!r}"
@@ -630,10 +679,11 @@ def version( # noqa: C901
630
679
  noop_report(f"would have uploaded the following assets: {runtime.assets}")
631
680
  else:
632
681
  try:
633
- release_id = hvcs_client.create_or_update_release(
682
+ hvcs_client.create_release(
634
683
  tag=new_version.as_tag(),
635
684
  release_notes=release_notes,
636
685
  prerelease=new_version.is_prerelease,
686
+ assets=assets,
637
687
  )
638
688
  except HTTPError as err:
639
689
  log.exception(err)
@@ -654,15 +704,4 @@ def version( # noqa: C901
654
704
  log.exception(e)
655
705
  ctx.fail(str(e))
656
706
 
657
- for asset in assets:
658
- log.info("Uploading asset %s", asset)
659
- try:
660
- hvcs_client.upload_asset(release_id, asset)
661
- except HTTPError as err:
662
- log.exception(err)
663
- ctx.fail(str.join("\n", [str(err), "Failed to upload asset!"]))
664
- except Exception as e:
665
- log.exception(e)
666
- ctx.fail(str(e))
667
-
668
707
  return str(new_version)