Skip to content

Commit

Permalink
Merge pull request #80 from callowayproject/minor-fixes
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
coordt authored Nov 4, 2023
2 parents 2bf48ff + 44c5208 commit 24222cb
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 109 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/bumpversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ on:
types: [closed]
branches: [master]
workflow_dispatch:
inputs:
dry_run:
description: Don't actually do the work, just describe it
default: true
type: boolean
new_version:
description: Set the version to a specific value
required: false
type: string
verbose:
description: The amount of output detail
default: 0
type: choice
options:
- "0"
- "1"
- "2"

jobs:
bumpversion:
Expand All @@ -38,8 +21,7 @@ jobs:

- name: Install requirements
run: |
python -m pip install generate-changelog
python -m pip install -e .
python -m pip install generate-changelog bump-my-version
- name: Git check
run: |
Expand All @@ -55,27 +37,44 @@ jobs:
echo "::notice::Suggested release type is: ${RELEASE_KIND}"
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
echo "PACKAGE=false" >> $GITHUB_ENV
- name: Bump Version auto
if: ${{ github.event_name != 'workflow_dispatch' }}
shell: bash
run: |
if [[ $RELEASE_KIND != "no-release" ]]; then
bump-my-version -v "$RELEASE_KIND"
bump-my-version bump -v "$RELEASE_KIND"
git push
git push --tags
echo "PACKAGE=true" >> $GITHUB_ENV
fi
- name: Bump Version manual
if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
env:
BUMPVERSION_DRY_RUN: ${{ inputs.dry_run }}
BUMPVERSION_NEW_VERSION: ${{ inputs.tags }}
BUMPVERSION_VERBOSE: ${{ inputs.verbose }}
run: |
bump-my-version -v "$RELEASE_KIND"
if [[ BUMPVERSION_DRY_RUN == "false" ]]; then
git push
git push --tags
fi
case "$RELEASE_KIND" in
major|minor|patch)
bump-my-version bump "$RELEASE_KIND"
if [[ BUMPVERSION_DRY_RUN == "false" ]]; then
git push
git push --tags
echo "PACKAGE=true" >> $GITHUB_ENV
fi
;;
dev)
bump-my-version bump -v --no-commit "$RELEASE_KIND"
echo "PACKAGE=true" >> $GITHUB_ENV
;;
esac
- name: Package
if: ${{ env.PACKAGE == 'true' }}
uses: hynek/build-and-inspect-python-package@v1

- name: Upload dev release to PyPI
if: ${{ env.PACKAGE == 'true' && env.RELEASE_KIND == 'dev' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ jobs:
- name: Set dev version
shell: bash
run: |
bumpversion dev bumpversion/__init__.py --no-commit --no-configured-files -v
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-configured-files -v
env:
GH_TOKEN: ${{ secrets.PAT }}

- name: Package
shell: bash
run: |
python -m pip install --disable-pip-version-check --no-python-version-warning build
python -m build
- name: Upload package to Test PyPI
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ on:

jobs:
# Package when a new tag is pushed
build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.PAT }}

- name: Package
uses: hynek/build-and-inspect-python-package@v1
# build-package:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# token: ${{ secrets.PAT }}
#
# - name: Package
# uses: hynek/build-and-inspect-python-package@v1

# Create a GitHub release
release:
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.290'
rev: 'v0.1.3'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: test.*
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -39,13 +39,13 @@ repos:
args: ['--baseline', '.secrets.baseline']
additional_dependencies: ["gibberish-detector"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
additional_dependencies: ["pydantic<2.0", "toml", "types-all"]
- repo: https://github.com/jsh9/pydoclint
rev: 0.3.2
rev: 0.3.8
hooks:
- id: pydoclint
args:
Expand All @@ -56,6 +56,6 @@ repos:
- id: interrogate
exclude: test.*
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
rev: 0.27.0
hooks:
- id: check-azure-pipelines
3 changes: 2 additions & 1 deletion bumpversion/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def resolve_command(self, ctx: Context, args: List[str]) -> tuple:
original_args.remove("bump")
else:
print_warning(
"Calling bumpversion without a subcommand is deprecated. " "Please use `bumpversion bump` instead"
"Calling bumpversion without a subcommand is deprecated. "
"Please use `bump-my-version bump` instead"
)
return cmd.name, cmd, original_args
return cmd.name, cmd, args
25 changes: 13 additions & 12 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
context_settings={
"ignore_unknown_options": True,
"allow_interspersed_args": True,
"help_option_names": ["-h", "--help"],
},
add_help_option=False,
)
Expand Down Expand Up @@ -140,10 +141,10 @@ def cli(ctx: Context) -> None:
help="Template for complete string to replace",
)
@click.option(
"--no-regex",
is_flag=True,
envvar="BUMPVERSION_NO_REGEX",
help="Do not treat the search parameter as a regular expression",
"--regex/--no-regex",
default=False,
envvar="BUMPVERSION_REGEX",
help="Treat the search parameter as a regular expression or explicitly do not treat it as a regular expression.",
)
@click.option(
"--no-configured-files",
Expand Down Expand Up @@ -232,7 +233,7 @@ def bump(
serialize: Optional[List[str]],
search: Optional[str],
replace: Optional[str],
no_regex: bool,
regex: bool,
no_configured_files: bool,
ignore_missing_version: bool,
dry_run: bool,
Expand Down Expand Up @@ -276,7 +277,7 @@ def bump(
message=message,
commit_args=commit_args,
ignore_missing_version=ignore_missing_version,
no_regex=no_regex,
regex=regex,
)

found_config_file = find_config_file(config_file)
Expand Down Expand Up @@ -417,10 +418,10 @@ def show(args: List[str], config_file: Optional[str], format_: str, increment: O
help="Template for complete string to replace",
)
@click.option(
"--no-regex",
is_flag=True,
envvar="BUMPVERSION_NO_REGEX",
help="Do not treat the search parameter as a regular expression",
"--regex/--no-regex",
default=False,
envvar="BUMPVERSION_REGEX",
help="Treat the search parameter as a regular expression or explicitly do not treat it as a regular expression.",
)
@click.option(
"--no-configured-files",
Expand Down Expand Up @@ -455,7 +456,7 @@ def replace(
serialize: Optional[List[str]],
search: Optional[str],
replace: Optional[str],
no_regex: bool,
regex: bool,
no_configured_files: bool,
ignore_missing_version: bool,
dry_run: bool,
Expand Down Expand Up @@ -485,7 +486,7 @@ def replace(
message=None,
commit_args=None,
ignore_missing_version=ignore_missing_version,
no_regex=no_regex,
regex=regex,
)

found_config_file = find_config_file(config_file)
Expand Down
16 changes: 9 additions & 7 deletions bumpversion/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FileConfig(BaseModel):
serialize: Optional[List[str]] = None # If different from outer scope
search: Optional[str] = None # If different from outer scope
replace: Optional[str] = None # If different from outer scope
no_regex: Optional[bool] = None # If different from outer scope
regex: Optional[bool] = None # If different from outer scope
ignore_missing_version: Optional[bool] = None


Expand All @@ -55,7 +55,7 @@ class Config(BaseSettings):
serialize: List[str] = Field(min_length=1)
search: str
replace: str
no_regex: bool
regex: bool
ignore_missing_version: bool
tag: bool
sign_tags: bool
Expand Down Expand Up @@ -86,7 +86,7 @@ def add_files(self, filename: Union[str, List[str]]) -> None:
serialize=self.serialize,
search=self.search,
replace=self.replace,
no_regex=self.no_regex,
regex=self.regex,
ignore_missing_version=self.ignore_missing_version,
)
)
Expand All @@ -107,10 +107,12 @@ def resolved_filemap(self) -> Dict[str, FileConfig]:
def files_to_modify(self) -> List[FileConfig]:
"""Return a list of files to modify."""
files_not_excluded = [
file_cfg.filename for file_cfg in self.files if file_cfg.filename not in self.excluded_paths
file_cfg.filename
for file_cfg in self.resolved_filemap.values()
if file_cfg.filename not in self.excluded_paths
]
inclusion_set = set(self.included_paths) | set(files_not_excluded)
return [file_cfg for file_cfg in self.files if file_cfg.filename in inclusion_set]
return [file_cfg for file_cfg in self.resolved_filemap.values() if file_cfg.filename in inclusion_set]

@property
def version_config(self) -> "VersionConfig":
Expand All @@ -126,7 +128,7 @@ def version_config(self) -> "VersionConfig":
"serialize": ["{major}.{minor}.{patch}"],
"search": "{current_version}",
"replace": "{new_version}",
"no_regex": False,
"regex": False,
"ignore_missing_version": False,
"tag": False,
"sign_tags": False,
Expand Down Expand Up @@ -157,7 +159,7 @@ def get_all_file_configs(config_dict: dict) -> List[FileConfig]:
"search": config_dict["search"],
"replace": config_dict["replace"],
"ignore_missing_version": config_dict["ignore_missing_version"],
"no_regex": config_dict["no_regex"],
"regex": config_dict["regex"],
}
files = [{k: v for k, v in filecfg.items() if v is not None} for filecfg in config_dict["files"]]
for f in files:
Expand Down
Loading

0 comments on commit 24222cb

Please sign in to comment.