diff --git a/.github/actions/release/action.yaml b/.github/actions/release/action.yaml index 649bb600..bde34d9d 100644 --- a/.github/actions/release/action.yaml +++ b/.github/actions/release/action.yaml @@ -1,15 +1,9 @@ name: Release description: Create a GitHub release and upload the package to PyPI inputs: - pypi-api-token: - description: 'PyPI API token' - required: true tag-name: description: 'The name of the tag for the GitHub release' required: true - github-token: - description: 'GitHub token' - required: true runs: using: "composite" @@ -31,9 +25,6 @@ runs: files: dist/* tag_name: "${{ inputs.tag-name }}" body_path: release-notes.md - token: ${{ inputs.github-token }} - name: Upload package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ inputs.pypi-api-token }} diff --git a/.github/actions/setup-python-and-git/action.yaml b/.github/actions/setup-python-and-git/action.yaml index 2471ab09..bb288ddb 100644 --- a/.github/actions/setup-python-and-git/action.yaml +++ b/.github/actions/setup-python-and-git/action.yaml @@ -4,19 +4,21 @@ inputs: python-version: description: 'Python version to use' required: false - default: '3.11' + default: '3.12' runs: using: 'composite' steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 name: Setup Python with: python-version: ${{ inputs.python-version }} - cache: 'pip' # caching pip dependencies - + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" - name: Git check run: | - git config --global user.email "bump-my-version@github.actions" + git config --global user.email "action@github.actions" git config --global user.name "Testing Git" git --version git config --list diff --git a/.github/workflows/docs-final.yml b/.github/workflows/docs-final.yml index 1c60edd6..87e24d80 100644 --- a/.github/workflows/docs-final.yml +++ b/.github/workflows/docs-final.yml @@ -19,18 +19,17 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.PAT }} - - name: Set up Python 3.10 - uses: actions/setup-python@v5 + - name: Setup Python and Git + uses: ./.github/actions/setup-python-and-git with: - python-version: "3.10" + python-version: '3.12' - name: Install dependencies run: | git pull --all - python -m pip install ".[docs]" + uv sync -p 3.12 --group docs - name: Build and deploy documentation run: | - mkdocs gh-deploy --strict -v + uv run mkdocs gh-deploy --strict diff --git a/.github/workflows/docs-preview.yml b/.github/workflows/docs-preview.yml index f2d30a05..18bbc2db 100644 --- a/.github/workflows/docs-preview.yml +++ b/.github/workflows/docs-preview.yml @@ -24,18 +24,17 @@ jobs: with: fetch-depth: 0 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 + - name: Setup Python and Git + uses: ./.github/actions/setup-python-and-git with: - python-version: "3.10" + python-version: '3.12' - name: Install dependencies - run: | - python -m pip install ".[docs]" + run: uv sync -p 3.12 --group docs - name: Build documentation run: | - mkdocs build --strict -v + uv run mkdocs build --strict - name: Deploy preview uses: rossjrw/pr-preview-action@v1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6df25b25..47c268cf 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -96,5 +96,3 @@ jobs: uses: ./.github/actions/release with: tag-name: ${{ env.TAG_NAME }} - github-token: ${{ secrets.PAT }} - pypi-api-token: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ccbd2376..486557f1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,30 +22,27 @@ jobs: - ubuntu-latest - windows-latest python-version: - - "3.8" - "3.9" - "3.10" - "3.11" + - "3.12" + - "3.13" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup-python-and-git with: python-version: ${{ matrix.python-version }} - - name: Check git is working - run: | - git config --global user.email "bumpversion-test-git@github.actions" - git config --global user.name "Testing Git" - git --version - git config --list - name: Check mercurial is working run: | echo -e '[ui]\nusername = Testing Mercurial' > ~/.hgrc hg --version - - name: Install test dependencies - run: pip install '.[test]' + - name: Install requirements + shell: bash + run: | + uv sync -p 3.12 --group dev --group test - name: Test - run: pytest --cov-report=xml + run: uv run pytest --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: @@ -59,23 +56,22 @@ jobs: release-test-pypi: name: Publish in-dev package to test.pypi.org runs-on: ubuntu-latest + permissions: + id-token: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.PAT }} ref: ${{ github.head_ref }} - - uses: actions/setup-python@v5 + - uses: ./.github/actions/setup-python-and-git with: - python-version: '3.11' - cache: 'pip' # caching pip dependencies + python-version: "3.12" - name: Install requirements shell: bash run: | - python -m pip install --disable-pip-version-check --no-python-version-warning build - python -m pip install --disable-pip-version-check --no-python-version-warning -e . + uv sync -p 3.12 --group dev - name: Set dev version shell: bash @@ -83,17 +79,14 @@ jobs: export PR_NUMBER=$(gh pr view --json number -q .number || echo "") echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV echo "::notice::PR_NUMBER is: ${PR_NUMBER}" - bump-my-version bump dev bumpversion/__init__.py --no-commit --no-tag --no-configured-files -v - env: - GH_TOKEN: ${{ secrets.PAT }} + uv run bump-my-version bump dev bumpversion/__init__.py --no-commit --no-tag --no-configured-files -v - name: Package shell: bash run: | - python -m build + uv build - name: Upload package to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository-url: https://test.pypi.org/legacy/ diff --git a/bumpversion/config/models.py b/bumpversion/config/models.py index d6ce3ef5..52fe228e 100644 --- a/bumpversion/config/models.py +++ b/bumpversion/config/models.py @@ -11,7 +11,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict from bumpversion.ui import get_indented_logger -from bumpversion.versioning.models import VersionComponentSpec # NOQA: TCH001 +from bumpversion.versioning.models import VersionComponentSpec # NOQA: TC001 if TYPE_CHECKING: from bumpversion.scm import SCMInfo diff --git a/bumpversion/ui.py b/bumpversion/ui.py index 8b8fa110..55dc191e 100644 --- a/bumpversion/ui.py +++ b/bumpversion/ui.py @@ -1,10 +1,14 @@ """Utilities for user interface.""" import logging +import sys import click from click import UsageError, secho from rich.logging import RichHandler +from rich.padding import Padding +from rich.panel import Panel +from rich_click.rich_help_formatter import RichHelpFormatter from bumpversion.indented_logger import IndentedLoggerAdapter @@ -50,4 +54,17 @@ def print_error(msg: str) -> None: def print_warning(msg: str) -> None: """Echo a warning to the console.""" - secho(f"\nWARNING:\n\n{msg}\n", fg="yellow") + formatter = RichHelpFormatter(file=sys.stderr) + config = formatter.config + + formatter.write( + Padding( + Panel( + formatter.highlighter(msg), + border_style="yellow", + title="Warning", + title_align=config.align_errors_panel, + ), + (0, 0, 1, 0), + ) + ) diff --git a/pyproject.toml b/pyproject.toml index d03c79ab..adba278f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ homepage = "https://github.com/callowayproject/bump-my-version" repository = "https://github.com/callowayproject/bump-my-version.git" documentation = "https://callowayproject.github.io/bump-my-version/" -[project.optional-dependencies] +[dependency-groups] dev = [ "git-fame>=1.12.2", "generate-changelog>=0.7.6", @@ -210,8 +210,6 @@ select = [ ignore = [ "ANN002", # missing-type-args "ANN003", # missing-type-kwargs - "ANN101", # missing-type-self - "ANN102", # missing-type-cls "ANN204", # missing-return-type-special-method "ANN401", # any-type "S101", # assert diff --git a/uv.lock b/uv.lock index 159b08cb..281275a3 100644 --- a/uv.lock +++ b/uv.lock @@ -137,7 +137,7 @@ dependencies = [ { name = "wcmatch" }, ] -[package.optional-dependencies] +[package.dev-dependencies] dev = [ { name = "generate-changelog" }, { name = "git-fame" }, @@ -173,35 +173,9 @@ test = [ [package.metadata] requires-dist = [ - { name = "black", marker = "extra == 'docs'" }, { name = "click" }, - { name = "coverage", marker = "extra == 'test'" }, - { name = "freezegun", marker = "extra == 'test'" }, - { name = "generate-changelog", marker = "extra == 'dev'", specifier = ">=0.7.6" }, - { name = "git-fame", marker = "extra == 'dev'", specifier = ">=1.12.2" }, - { name = "markdown-customblocks", marker = "extra == 'docs'" }, - { name = "mdx-truly-sane-lists", marker = "extra == 'docs'" }, - { name = "mkdocs", marker = "extra == 'docs'" }, - { name = "mkdocs-click", marker = "extra == 'docs'" }, - { name = "mkdocs-drawio", marker = "extra == 'docs'" }, - { name = "mkdocs-gen-files", marker = "extra == 'docs'" }, - { name = "mkdocs-git-authors-plugin", marker = "extra == 'docs'" }, - { name = "mkdocs-git-committers-plugin", marker = "extra == 'docs'" }, - { name = "mkdocs-git-revision-date-localized-plugin", marker = "extra == 'docs'", specifier = ">=1.2.6" }, - { name = "mkdocs-include-markdown-plugin", marker = "extra == 'docs'" }, - { name = "mkdocs-literate-nav", marker = "extra == 'docs'" }, - { name = "mkdocs-material", marker = "extra == 'docs'" }, - { name = "mkdocstrings", extras = ["python"], marker = "extra == 'docs'" }, - { name = "pip-tools", marker = "extra == 'dev'" }, - { name = "pre-commit", marker = "extra == 'dev'" }, - { name = "pre-commit", marker = "extra == 'test'" }, { name = "pydantic", specifier = ">=2.0.0" }, { name = "pydantic-settings" }, - { name = "pytest", marker = "extra == 'test'" }, - { name = "pytest-cov", marker = "extra == 'test'" }, - { name = "pytest-mock", marker = "extra == 'test'" }, - { name = "pytest-sugar", marker = "extra == 'test'" }, - { name = "python-frontmatter", marker = "extra == 'docs'" }, { name = "questionary" }, { name = "rich" }, { name = "rich-click" }, @@ -209,6 +183,40 @@ requires-dist = [ { name = "wcmatch", specifier = ">=8.5.1" }, ] +[package.metadata.requires-dev] +dev = [ + { name = "generate-changelog", specifier = ">=0.7.6" }, + { name = "git-fame", specifier = ">=1.12.2" }, + { name = "pip-tools" }, + { name = "pre-commit" }, +] +docs = [ + { name = "black" }, + { name = "markdown-customblocks" }, + { name = "mdx-truly-sane-lists" }, + { name = "mkdocs" }, + { name = "mkdocs-click" }, + { name = "mkdocs-drawio" }, + { name = "mkdocs-gen-files" }, + { name = "mkdocs-git-authors-plugin" }, + { name = "mkdocs-git-committers-plugin" }, + { name = "mkdocs-git-revision-date-localized-plugin", specifier = ">=1.2.6" }, + { name = "mkdocs-include-markdown-plugin" }, + { name = "mkdocs-literate-nav" }, + { name = "mkdocs-material" }, + { name = "mkdocstrings", extras = ["python"] }, + { name = "python-frontmatter" }, +] +test = [ + { name = "coverage" }, + { name = "freezegun" }, + { name = "pre-commit" }, + { name = "pytest" }, + { name = "pytest-cov" }, + { name = "pytest-mock" }, + { name = "pytest-sugar" }, +] + [[package]] name = "certifi" version = "2024.8.30"