Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ jobs:
# see https://docs.pypi.org/trusted-publishers/
- name: Publish package distributions to PyPI
id: pypi-publish
uses: pypa/gh-action-pypi-publish@v1.13.0
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
packages-dir: dist
print-hash: true
Expand Down
6 changes: 5 additions & 1 deletion docs/configuration/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,8 @@ The regular expression generated from the ``version_variables`` definition will:
2. The variable name defined by ``variable`` and the version must be separated by
an operand symbol (``=``, ``:``, ``:=``, or ``@``). Whitespace is optional around
the symbol. As of v10.0.0, a double-equals (``==``) operator is also supported
as a valid operand symbol.
as a valid operand symbol. As of $NEW_RELEASE_TAG, PSR can omit all operands as long
as there is at least one whitespace character between the variable name and the version.

3. The value of the variable must match a `SemVer`_ regular expression and can be
enclosed by single (``'``) or double (``"``) quotation marks but they must match. However,
Expand Down Expand Up @@ -1410,6 +1411,9 @@ will be matched and replaced by the new version:
# requirements.txt
my-package == 1.2.3

# C-Macro style (no operand only whitespace required)
#define VERSION "1.2.3"

.. important::
The Regular Expression expects a version value to exist in the file to be replaced.
It cannot be an empty string or a non-semver compliant string. If this is the very
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ build = [
"build ~= 1.2"
]
docs = [
"Sphinx ~= 6.0",
"sphinxcontrib-apidoc == 0.5.0",
"Sphinx ~= 7.4",
"sphinxcontrib-apidoc == 0.6.0",
"sphinx-autobuild == 2024.2.4",
"furo ~= 2024.1",
"furo ~= 2025.9",
]
test = [
"coverage[toml] ~= 7.0",
Expand All @@ -68,9 +68,9 @@ test = [
"pyyaml ~= 6.0",
"pytest ~= 8.3",
"pytest-clarity ~= 1.0",
"pytest-cov >= 5.0.0, < 7.0.0",
"pytest-cov >= 5.0.0, < 8.0.0",
"pytest-env ~= 1.0",
"pytest-lazy-fixtures ~= 1.3.4",
"pytest-lazy-fixtures ~= 1.4",
"pytest-mock ~= 3.0",
"pytest-order ~= 1.3",
"pytest-pretty ~= 1.2",
Expand Down
23 changes: 23 additions & 0 deletions scripts/watch_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if command -v realpath >/dev/null 2>&1; then
PROJ_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")/..")
elif command -v readlink >/dev/null 2>&1; then
PROJ_ROOT=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")
else
PROJ_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
fi

[ -z "$VIRTUAL_ENV" ] && VIRTUAL_ENV=".venv"
SPHINX_AUTOBUILD_EXE="$VIRTUAL_ENV/bin/sphinx-autobuild"

cd "$PROJ_ROOT" || exit 1

if [ ! -f "$SPHINX_AUTOBUILD_EXE" ]; then
printf '%s\n' "sphinx-autobuild is not installed in the virtual environment. Please install the docs extras."
exit 1
fi

rm -rf docs/_build/html docs/api/modules

exec "$SPHINX_AUTOBUILD_EXE" docs docs/_build/html --open-browser --port 9000 --ignore docs/api/modules
4 changes: 2 additions & 2 deletions src/semantic_release/version/declarations/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def from_string_definition(
# Negative lookbehind to ensure we don't match part of a variable name
f"""(?x)(?P<quote1>['"])?(?<![\\w.-]){regex_escape(variable)}(?P=quote1)?""",
# Supports walrus, equals sign, double-equals, colon, or @ as assignment operator
# ignoring whitespace separation
r"\s*(:=|==|[:=@])\s*",
# ignoring whitespace separation. Also allows a space as the separator for c-macro style definitions.
r"\s*(:=|==|[:=@ ])\s*",
# Supports optional matching quotations around a version pattern (tag or raw format)
f"""(?P<quote2>['"])?{value_replace_pattern_str}(?P=quote2)?""",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,59 @@ def test_pattern_declaration_is_version_replacer():
"""
),
),
(
"Using default number format for c-macro style definition (see #1348)",
f"{test_file}:APP_VERSION:{VersionStampType.NUMBER_FORMAT.value}",
# irrelevant for this case
lazy_fixture(default_tag_format_str.__name__),
# Uses colon separator with double quotes
dedent(
"""\
#ifndef VERSION_H
#define VERSION_H

#define APP_VERSION "0.0.0"

#endif // VERSION_H
"""
),
dedent(
f"""\
#ifndef VERSION_H
#define VERSION_H

#define APP_VERSION "{next_version}"

#endif // VERSION_H
"""
),
),
(
"Using default tag format for c-macro style definition (see #1348)",
f"{test_file}:APP_VERSION:{VersionStampType.TAG_FORMAT.value}",
lazy_fixture(default_tag_format_str.__name__),
# Uses colon separator with double quotes
dedent(
"""\
#ifndef VERSION_H
#define VERSION_H

#define APP_VERSION "v0.0.0"

#endif // VERSION_H
"""
),
dedent(
f"""\
#ifndef VERSION_H
#define VERSION_H

#define APP_VERSION "v{next_version}"

#endif // VERSION_H
"""
),
),
]
],
)
Expand Down
Loading