diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e3148a9fb..cb807c1b5 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -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 diff --git a/docs/configuration/configuration.rst b/docs/configuration/configuration.rst index 2b2278382..cdd3604fb 100644 --- a/docs/configuration/configuration.rst +++ b/docs/configuration/configuration.rst @@ -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, @@ -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 diff --git a/pyproject.toml b/pyproject.toml index e5629a06e..45c9c2ea1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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", diff --git a/scripts/watch_docs.sh b/scripts/watch_docs.sh new file mode 100644 index 000000000..e3608442e --- /dev/null +++ b/scripts/watch_docs.sh @@ -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 diff --git a/src/semantic_release/version/declarations/pattern.py b/src/semantic_release/version/declarations/pattern.py index f08c208a4..4d285b5a1 100644 --- a/src/semantic_release/version/declarations/pattern.py +++ b/src/semantic_release/version/declarations/pattern.py @@ -228,8 +228,8 @@ def from_string_definition( # Negative lookbehind to ensure we don't match part of a variable name f"""(?x)(?P['"])?(?['"])?{value_replace_pattern_str}(?P=quote2)?""", ], diff --git a/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py b/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py index 8280e95bb..ddca3dbf6 100644 --- a/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py +++ b/tests/unit/semantic_release/version/declarations/test_pattern_declaration.py @@ -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 + """ + ), + ), ] ], )