diff --git a/docs/assets/explanations.jpg b/docs/assets/explanations.jpg new file mode 100644 index 00000000..b592487f Binary files /dev/null and b/docs/assets/explanations.jpg differ diff --git a/docs/assets/how-to.jpg b/docs/assets/how-to.jpg new file mode 100644 index 00000000..12139d7d Binary files /dev/null and b/docs/assets/how-to.jpg differ diff --git a/docs/assets/reference.jpg b/docs/assets/reference.jpg new file mode 100644 index 00000000..0efd8e45 Binary files /dev/null and b/docs/assets/reference.jpg differ diff --git a/docs/assets/tutorial.jpg b/docs/assets/tutorial.jpg new file mode 100644 index 00000000..6f3ecdc7 Binary files /dev/null and b/docs/assets/tutorial.jpg differ diff --git a/docs/explanation/index.md b/docs/explanation/index.md index b1303b40..9a23d53e 100644 --- a/docs/explanation/index.md +++ b/docs/explanation/index.md @@ -1 +1 @@ -# Explanation +- *.md diff --git a/docs/reference/subcommands/show.md b/docs/explanation/show-subcommand.md similarity index 100% rename from docs/reference/subcommands/show.md rename to docs/explanation/show-subcommand.md diff --git a/docs/reference/version-parts.md b/docs/explanation/version-parts.md similarity index 99% rename from docs/reference/version-parts.md rename to docs/explanation/version-parts.md index 06900061..61fe606a 100644 --- a/docs/reference/version-parts.md +++ b/docs/explanation/version-parts.md @@ -1,4 +1,4 @@ -# Version parts +# Version components - The version string is the rendering of some or all version parts. - While the version string may be rendered differently in various places, the value for all parts is maintained in Bump My Version's configuration. diff --git a/docs/gen_doc_stubs.py b/docs/gen_doc_stubs.py index c2a3bf2f..605b78b4 100755 --- a/docs/gen_doc_stubs.py +++ b/docs/gen_doc_stubs.py @@ -47,5 +47,5 @@ mkdocs_gen_files.set_edit_path(full_doc_path, path) -with mkdocs_gen_files.open("reference/api/SUMMARY.md", "w") as nav_file: +with mkdocs_gen_files.open("reference/api/nav.md", "w") as nav_file: nav_file.writelines(nav.build_literate_nav()) diff --git a/docs/howtos/avoid-incorrect-replacements.md b/docs/howtos/avoid-incorrect-replacements.md index c7997fbb..b077c15f 100644 --- a/docs/howtos/avoid-incorrect-replacements.md +++ b/docs/howtos/avoid-incorrect-replacements.md @@ -1,4 +1,4 @@ -# Avoiding incorrect replacements +# Avoid incorrect replacements In files that have multiple version strings, Bump My Version may find the wrong string and replace it. Given this `requirements.txt` for `MyProject`: diff --git a/docs/howtos/calver.md b/docs/howtos/calver.md index 3a63a57d..406dfd83 100644 --- a/docs/howtos/calver.md +++ b/docs/howtos/calver.md @@ -7,7 +7,6 @@ For this example, we will use the following format: `YYYY.MM.DD.patch`. It will - `2022.2.1` for the first patch of February 1, 2022 - `2022.2.1.1` for the second patch of February 1, 2022 - ## Initial configuration ```toml title=".bumpversion.toml" @@ -31,7 +30,12 @@ You can look up the regular expressions for the CalVer format in the [CalVer ref ## Expected behavior -You can find out more about the logic behind the CalVer incrementing in the [CalVer reference](../reference/calver_reference.md#calver-incrementing-logic). +- CalVer version components are marked as `always_increment` by default. +- When bumping a version, you specify which component to increment. It is called the target component. +- When bumping a version, the components marked as `always_increment` are incremented first. +- If an `always_increment` component's value changed, its dependent components are marked for reset to their default values. +- If the target component is in the set of components marked for reset, the target component is reset to its default value. +- If the target component is not in the set of components marked for reset, the target component is incremented and its dependent components are reset to their default values. ### Bumping the release resets the patch part diff --git a/docs/index.md b/docs/index.md index 5626cde8..e7dd5b72 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,10 +5,56 @@ title: Bump My Version # Bump My Version -{% - include-markdown - "../README.md" - start="" - end="" - rewrite-relative-urls=false -%} +::: grid wide-gap + + ::: card-container + + ::: card-media + + ![Tutorials](assets/tutorial.jpg) + + ::: card-content + + [Tutorials](tutorials/getting-started.md) + { .card-content-title } + + Follow along with our guides to learn how to use Bump My Version. + + ::: card-container + + ::: card-media + + ![Reference](assets/reference.jpg) + + ::: card-content + + [Reference](reference/index.md) + { .card-content-title } + + Consult the reference for specifics about the Bump My Version's configuration and commands. + + ::: card-container + + ::: card-media + + ![How-To's](assets/how-to.jpg) + + ::: card-content + + [How-To's](howtos/index.md) + { .card-content-title } + + Need to get something done? Check out our how-to guides. + + ::: card-container + + ::: card-media + + ![Explanations](assets/explanations.jpg) + + ::: card-content + + [Explanations](explanation/index.md) + { .card-content-title } + + Want to understand the library better? Read our explanations behind the design. diff --git a/docs/reference/calver_reference.md b/docs/reference/calver_reference.md index 7a0c8ed3..9580810c 100644 --- a/docs/reference/calver_reference.md +++ b/docs/reference/calver_reference.md @@ -2,7 +2,9 @@ ## Calendar versioning codes -The following table lists the available format codes for calendar versioning (CalVer) schemes. The codes can be used to define the version format in the `calver_format` configuration options. Formatting codes, surrounded by `{ }` can be combined to create a custom version format. For example, the format `YYYY.MM.DD` can be defined as `"{YYYY}.{MM}.{DD}"`. +The following table lists the available format codes for calendar versioning (CalVer) schemes. The codes can be used to +define the version format in the `calver_format` configuration options. Formatting codes, surrounded by `{ }` can be +combined to create a custom version format. For example, the format `YYYY.MM.DD` can be defined as `"{YYYY}.{MM}.{DD}"`. | Code | Example(s) | Comment | |--------|---------------------|-----------------------------------------------| @@ -32,7 +34,6 @@ The following table lists the available format codes for calendar versioning (Ca calver_format = "{YYYY}.{MM}.{DD}" ``` - ## Parsing CalVer versions Using the following chart, we can set up the version parsing: @@ -68,7 +69,9 @@ Using the following chart, we can set up the version parsing: `(?:jan|fév|mar|avr|mai|jui|jui|aoû|sep|oct|nov|déc)` for French -You can use these regular expressions to parse CalVer versions in your project. For example, the following `parse` configuration can be used to parse a version string in the format `YYYY.MM.DD` as the `release` part of the version string: +You can use these regular expressions to parse CalVer versions in your project. For example, the following `parse` +configuration can be used to parse a version string in the format `YYYY.MM.DD` as the `release` part of the version +string: ```toml [tool.bumpversion] @@ -80,12 +83,3 @@ parse = """(?x) # Verbose mode ) """ ``` - -## CalVer incrementing logic - -- CalVer version components are marked as `always_increment` by default. -- When bumping a version, you specify which component to increment. It is called the target component. -- When bumping a version, the components marked as `always_increment` are incremented first. -- If an `always_increment` component's value changed, its dependent components are marked for reset to their default values. -- If the target component is in the set of components marked for reset, the target component is reset to its default value. -- If the target component is not in the set of components marked for reset, the target component is incremented and its dependent components are reset to their default values. diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md deleted file mode 100644 index dac2c5ed..00000000 --- a/docs/reference/configuration.md +++ /dev/null @@ -1,805 +0,0 @@ -# Configuration - -Bump My Version looks in three places for configuration information (in order of precedence): - -1. command line -2. configuration file -3. environment variables - - -## Configuration files - -Bump My Version looks in four places for the configuration file to parse (in order of precedence): - -1. `--config-file ` _(command line argument)_ -2. `BUMPVERSION_CONFIG_FILE=file` _(environment variable)_ -3. `.bumpversion.cfg` _(legacy)_ -4. `.bumpversion.toml` -5. `setup.cfg` _(legacy)_ -6. `pyproject.toml` - -`.toml` files are recommended. We will likely drop support for `ini`-style formats in the future. You should add your configuration file to your source code management system. - -By using a configuration file, you no longer need to specify those options on the command line. The configuration file also allows greater flexibility in specifying how files are modified. - - -## Global Configuration - -The general configuration is grouped in a `[tool.bumpversion]` or `[bumpversion]` section, depending on if it is a TOML or INI file, respectfully. - -### allow_dirty - -::: field-list - required - : No - - default - : `False` - - type - : boolean - - command line option - : `--allow-dirty | --no-allow-dirty` - - environment var - : `BUMPVERSION_ALLOW_DIRTY` - - -Bump-my-version's default behavior is to abort if the working directory has uncommitted changes. This protects you from releasing unversioned files and overwriting unsaved changes. - -### commit - -::: field-list - required - : No - - default - : `False` (Don't create a commit) - - type - : boolean - - command line option - : `--commit | --no-commit` - - environment var - : `BUMPVERSION_COMMIT` - -Whether to create a commit using git or Mercurial. - -If you have pre-commit hooks, add an option to [`commit_args`](configuration.md#commit_args) to turn off your pre-commit hooks. For Git, use `--no-verify` and use `--config hooks.pre-commit=` for Mercurial. - -### commit_args - -::: field-list - - required - : No - - default - : `""` - - type - : string - - command line option - : `--commit-args` - - environment var - : `BUMPVERSION_COMMIT_ARGS` - -Extra arguments to pass to commit command. This is only used when the [`commit`](configuration.md#commit) option is set to `True`. - -If you have pre-commit hooks, add an option to turn off your pre-commit hooks. For Git, use `--no-verify` and use `--config hooks.pre-commit=` for Mercurial. - -### current_version - -::: field-list - - required - : **Yes** - - default - : `""` - - type - : string - - command line option - : `--current-version` - - environment var - : `BUMPVERSION_CURRENT_VERSION` - -The current version of the software package before bumping. A value for this is required. - -### ignore_missing_files - -::: field-list - - required - : No - - default - : `False` - - type - : boolean - - command line option - : `--ignore-missing-files` - - environment var - : `BUMPVERSION_IGNORE_MISSING_FILES` - -If `True`, don't fail if the configured file is missing. - -### ignore_missing_version - -::: field-list - required - : No - - default - : `False` - - type - : boolean - - command line option - : `--ignore-missing-version` - - environment var - : `BUMPVERSION_IGNORE_MISSING_VERSION` - -If `True`, don't fail if the version string to be replaced is not found in the file. - -### message - -::: field-list - - required - : No - - default - : `Bump version: {current_version} → {new_version}` - - type - : string - - command line option - : `--message` - - environment var - : `BUMPVERSION_MESSAGE` - -The commit message template to use when creating a commit. This is only used when the [`commit`](configuration.md#commit) option is set to `True`. - -This string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](formatting-context.md) describes the available variables. - -### parse - -::: field-list - required - : No - - default - : `(?P\d+)\.(?P\d+)\.(?P\d+)` - - type - : string - - command line option - : `--parse` - - environment var - : `BUMPVERSION_PARSE` - -This is the default regular expression ([Python regular expression syntax](https://docs.python.org/3/library/re.html#regular-expression-syntax)) for finding and parsing the version string into its components. Individual part or file configurations may override this. - -The regular expression must be able to parse all strings produced by the configured [`serialize`](configuration.md#serialize) value. Named matching groups ("`(?P...)`") indicate the version part the matched value belongs to. - -### regex - -::: field-list - - required - : No - - default - : `False` - - type - : boolean - - command line option - : `--regex | --no-regex` - - environment var - : `BUMPVERSION_REGEX` - -Treat the `search` string as a regular expression. - -### replace - -::: field-list - required - : No - - default - : `{new_version}` - - type - : string - - command line option - : `--replace` - - environment var - : `BUMPVERSION_REPLACE` - -This is the template to create the string that will replace the current version number in the file. - -### search - -::: field-list - required - : No - - default - : `{current_version}` - - type - : string - - command line option - : `--search` - - environment var - : `BUMPVERSION_SEARCH` - -This is the template string for searching. It is rendered using the [formatting context](formatting-context.md) for searching in the file. Individual file configurations may override this. This can span multiple lines and is templated using [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](formatting-context.md) describes the available variables. - -This is useful if there is the remotest possibility that the current version number might be present multiple times in the file and you mean to bump only one of the occurrences. - -### serialize - -::: field-list - required - : No - - default - : `["{major}.{minor}.{patch}"]` - - type - : an array of strings - - command line option - : `--serialize` - - environment var - : `BUMPVERSION_SERIALIZE` - -This is the default list of templates specifying how to serialize the version parts back to a version string. Individual part or file configurations may override this. - -Since version parts can be optional, bumpversion will try the serialization formats beginning with the first and choose the last one where all values can all non-optional values are represented. - -In this example (in TOML): - -```toml -serialize = [ - "{major}.{minor}.{patch}", - "{major}.{minor}", - "{major}" -] -``` - -Since `0` is optional by default, Version `1.8.9` will serialize to `1.8.9`, `1.9.0` will serialize to `1.9`, and version `2.0.0` will serialize as `2`. - -Each string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](formatting-context.md) describes the available variables. - -### sign_tags - -::: field-list - - required - : No - - default - : `False` (Don't sign tags) - - type - : boolean - - command line option - : `--sign-tags | --no-sign-tags` - - environment var - : `BUMPVERSION_SIGN_TAGS` - -If `True`, sign the created tag, when [`tag`](configuration.md#tag) is `True`. - -### tag - -::: field-list - - required - : No - - default - : `False` (Don't create a tag) - - type - : boolean - - command line option - : `--tag | --no-tag` - - environment var - : `BUMPVERSION_TAG` - -If `True`, create a tag after committing the changes. The tag is named using the [`tag_name`](configuration.md#tag_name) option. - -If you are using `git`, don't forget to `git-push` with the `--tags` flag when you are done. - -### tag_message - -::: field-list - required - : No - - default - : `Bump version: {current_version} → {new_version}` - - type - : string - - command line option - : `--tag-message` - - environment var - : `BUMPVERSION_TAG_MESSAGE` - -The tag message template to use when creating a tag when [`tag`](configuration.md#tag) is `True` - -This string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](formatting-context.md) describes the available variables. - -Bump My Version creates an *annotated* tag in Git by default. To turn this off and create a *lightweight* tag, you must explicitly set an empty `tag_message` value. - -### tag_name - -::: field-list - - required - : No - - default - : `v{new_version}` - - type - : string - - command line option - : `--tag-name` - - environment var - : `BUMPVERSION_TAG_NAME` - -The template used to render the tag when [`tag`](configuration.md#tag) is `True`. - -This string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](formatting-context.md) describes the available variables. - -### Examples - -=== "TOML" - - ```toml - [tool.bumpversion] - allow_dirty = false - commit = false - message = "Bump version: {current_version} → {new_version}" - commit_args = "" - tag = false - sign_tags = false - tag_name = "v{new_version}" - tag_message = "Bump version: {current_version} → {new_version}" - current_version = "1.0.0" - parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" - serialize = [ - "{major}.{minor}.{patch}" - ] - search = "{current_version}" - replace = "{new_version}" - ``` - -=== "CFG" - - ```ini - [bumpversion] - allow_dirty = False - commit = False - message = Bump version: {current_version} → {new_version} - commit_args = - tag = False - sign_tags = False - tag_name = v{new_version} - tag_message = Bump version: {current_version} → {new_version} - current_version = 1.0.0 - parse = (?P\d+)\.(?P\d+)\.(?P\d+) - serialize = - {major}.{minor}.{patch} - search = {current_version} - replace = {new_version} - ``` - -## Version part-specific configuration - -Version part configuration is grouped in a `[tool.bumpversion.parts.]` or `[bumpversion:part:]` section, depending on if it is a TOML or INI file, respectfully. - -You only need to configure version parts if they deviate from the default, and then you only need to specify the overridden options. - -### values - -::: field-list - required - : No - - default - : numeric (i.e. `0`, `1`, `2`, …) - - type - : array of strings - -An explicit list of all values to iterate through when bumping this part. An empty array is treated as indicating `numeric` values. - -### optional_value - -::: field-list - required - : No - - default - : The first entry in `values`, `0` when using numeric values - - type - : string - -When the version part matches this value, it is considered optional when serializing the final version string. - -!!! note - - Numeric values are still treated as strings internally, so when specifying an optional value, you must use a string. - - -### first_value - -::: field-list - required - : No - - default - : The first entry in `values`, `0` when using numeric values - - type - : string - -When the part is reset, the value will be set to the value specified here. - -!!! note - - Numeric values are still treated as strings internally, so when specifying a first value, you must use a string. - - -### independent - -::: field-list - required - : No - - default - : `False` - - type - : boolean - -When this value is set to `True`, the part is not reset when other parts are incremented. Its incrementation is -independent of the other parts. It is useful when you have a build number in your version that is incremented independently of the actual version. - -### always_increment - -::: field-list - required - : No - - default - : `False` (`True` if `calver_format` is set) - - type - : boolean - -When this value is set to `True`, the part is always incremented when the version is bumped, regardless of the target part. - - -### calver_format - -::: field-list - required - : No - - default - : empty - - type - : string - -The `calver_format` is a string that specifies the format of the version part. It is used to determine the next value when bumping the version. The format is a string that uses the placeholders defined in the [CalVer reference](calver_reference.md#calver_format). - -### Examples - -=== "TOML" - - ```toml - [tool.bumpversion.parts.release] - values = [ - "alpha", - "beta", - "gamma" - ] - optional_value = "gamma" - ``` - -=== "CFG" - - ```ini - [bumpversion:part:release] - optional_value = gamma - values = - alpha - beta - gamma - ``` - - -## File-specific configuration - -This section configures which files Bump My Version should update by replacing their current version with the newly bumped version. - -### filename - -::: field-list - required - : **Yes‡** - - default - : empty - - type - : string - -The name of the file to modify. - -!!! note - - ‡ This is only used with TOML configuration and is only required if [`glob`](#glob) is _not_ specified. INI-style configuration files specify the file name as part of the grouping. - - -### glob - -::: field-list - required - : **Yes‡** - - - default - : empty - - type - : string - -The glob pattern specifying the files to modify. - -!!! note - - ‡ This is only used with TOML configuration, and is only required if [`filename`](#filename) is _not_ specified. INI-style configuration files specify the glob pattern as part of the grouping. - -### glob_exclude - -::: field-list - required - : No - - default - : empty - - type - : list of string - -A list of glob patterns to exclude from the files found via the `glob` parameter. Does nothing if `filename` is specified. - - -### parse - -::: field-list - - required - : No - - default - : the value configured in the global `parse` field - - type - : string - -This is an override to the default pattern to parse the version number from this file. - -### serialize - -::: field-list - - required - : No - - default - : the value configured in the global `serialize` field - - type - : an array of strings - -This is an override to the default templates to serialize the new version number in this file. - -### search - -::: field-list - - required - : No - - default - : the value configured in the global `search` field - - type - : string - -This is an override to the default template string how to search for the string to be replaced in the file. - -### regex - -::: field-list - - required - : No - - default - : the value configured in the global `regex` field - - type - : boolean - -If `True`, treat the `search` parameter as a regular expression. - -### replace - -::: field-list - - required - : No - - default - : the value configured in the global `replace` field - - type - : string - -This is an override to the template to create the string that will replace the current version number in the file. - -### ignore_missing_version - -::: field-list - - required - : No - - default - : The value configured in the global `ignore_missing_version` field - - type - : boolean - -If `True`, don't fail if the version string to be replaced is not found in the file. - -### ignore_missing_file - -::: field-list - - required - : No - - default - : The value configured in the global `ignore_missing_file` field - - type - : boolean - -if `True`, don't fail if the configured file is missing. - -### include_bumps - -::: field-list - - required - : No - - default - : all version components - - type - : list of strings - -The `include_bumps` file configuration allows you to control when bump-my-version includes this file for changes. Its alternative is the `exclude_bumps` configuration. When a `bump ` command is issued, this file is changed only if the version component is in this list and not in [`exclude_bumps`](#exclude_bumps). The [parse](#parse) configuration defines version components. - -The default value, or an empty list, includes all version components. - -### exclude_bumps - -::: field-list - - required - : No - - default - : `[]` - - type - : list of strings - -The `exclude_bumps` file configuration allows you to control when bump-my-version excludes this file for changes. Its alternative is the `include_bumps` configuration. When a `bump ` command is issued, this file is only changed if the version component is *not in this list.* The [parse](#parse) configuration defines version components. - -The default value does not exclude anything. - -### Examples - -=== "TOML" - - TOML allows us to specify the files using an [array of tables.](https://toml.io/en/v1.0.0#array-of-tables) TOML configuration adds two fields to each file configuration: `filename` and `glob`. These fields are mutually exclusive: if you specify a value for both, only the `glob` value is used. - - For example, to change `coolapp/__init__.py` with the defaults and alter `CHANGELOG.md` twice: - - ```toml - [[tool.bumpversion.files]] - filename = "coolapp/__init__.py" - - [[tool.bumpversion.files]] - filename = "CHANGELOG.md" - search = "Unreleased" - - [[tool.bumpversion.files]] - filename = "CHANGELOG.md" - search = "{current_version}...HEAD" - replace = "{current_version}...{new_version}" - ``` - -=== "CFG" - - INI-style configuration is in the section: `[bumpversion:file:]` or `[bumpversion:glob:]`. - - Both, `file:` and `glob:` are configured the same. Their difference is that file will match file names directly like `requirements.txt`. While glob also matches multiple files via wildcards like `**/pom.xml`. - - !!! note - - The configuration file format requires each section header to be unique. If you want to process a certain file multiple times, you may append a description between parens to the `file` keyword: `[bumpversion:file (special one):…]`. - - - - For example, to change `coolapp/__init__.py` with the defaults and alter `CHANGELOG.md` twice: - - ```ini - [bumpversion:file:coolapp/__init__.py] - - [bumpversion:file(version heading):CHANGELOG.md] - search = Unreleased - - [bumpversion:file(previous version):CHANGELOG.md] - search = {current_version}...HEAD - replace = {current_version}...{new_version} - ``` diff --git a/docs/reference/configuration/file.md b/docs/reference/configuration/file.md new file mode 100644 index 00000000..b678e262 --- /dev/null +++ b/docs/reference/configuration/file.md @@ -0,0 +1,249 @@ +--- +title: File-specific Configuration +description: Configuration for changing files +icon: +date: 2024-08-11 +comments: true +--- +# File-specific configuration + +This section configures which files Bump My Version should update by replacing their current version with the newly bumped version. + +## filename + +::: field-list + required + : **Yes‡** + + default + : empty + + type + : string + +The name of the file to modify. + +!!! note + + ‡ This is only used with TOML configuration and is only required if [`glob`](#glob) is _not_ specified. INI-style configuration files specify the file name as part of the grouping. + + +## glob + +::: field-list + required + : **Yes‡** + + + default + : empty + + type + : string + +The glob pattern specifying the files to modify. + +!!! note + + ‡ This is only used with TOML configuration, and is only required if [`filename`](#filename) is _not_ specified. INI-style configuration files specify the glob pattern as part of the grouping. + +## glob_exclude + +::: field-list + required + : No + + default + : empty + + type + : list of string + +A list of glob patterns to exclude from the files found via the `glob` parameter. Does nothing if `filename` is specified. + + +## parse + +::: field-list + + required + : No + + default + : the value configured in the global `parse` field + + type + : string + +This is an override to the default pattern to parse the version number from this file. + +## serialize + +::: field-list + + required + : No + + default + : the value configured in the global `serialize` field + + type + : an array of strings + +This is an override to the default templates to serialize the new version number in this file. + +## search + +::: field-list + + required + : No + + default + : the value configured in the global `search` field + + type + : string + +This is an override to the default template string how to search for the string to be replaced in the file. + +## regex + +::: field-list + + required + : No + + default + : the value configured in the global `regex` field + + type + : boolean + +If `True`, treat the `search` parameter as a regular expression. + +## replace + +::: field-list + + required + : No + + default + : the value configured in the global `replace` field + + type + : string + +This is an override to the template to create the string that will replace the current version number in the file. + +## ignore_missing_version + +::: field-list + + required + : No + + default + : The value configured in the global `ignore_missing_version` field + + type + : boolean + +If `True`, don't fail if the version string to be replaced is not found in the file. + +## ignore_missing_file + +::: field-list + + required + : No + + default + : The value configured in the global `ignore_missing_file` field + + type + : boolean + +if `True`, don't fail if the configured file is missing. + +## include_bumps + +::: field-list + + required + : No + + default + : all version components + + type + : list of strings + +The `include_bumps` file configuration allows you to control when bump-my-version includes this file for changes. Its alternative is the `exclude_bumps` configuration. When a `bump ` command is issued, this file is changed only if the version component is in this list and not in [`exclude_bumps`](#exclude_bumps). The [parse](#parse) configuration defines version components. + +The default value, or an empty list, includes all version components. + +## exclude_bumps + +::: field-list + + required + : No + + default + : `[]` + + type + : list of strings + +The `exclude_bumps` file configuration allows you to control when bump-my-version excludes this file for changes. Its alternative is the `include_bumps` configuration. When a `bump ` command is issued, this file is only changed if the version component is *not in this list.* The [parse](#parse) configuration defines version components. + +The default value does not exclude anything. + +## Examples + +=== "TOML" + + TOML allows us to specify the files using an [array of tables.](https://toml.io/en/v1.0.0#array-of-tables) TOML configuration adds two fields to each file configuration: `filename` and `glob`. These fields are mutually exclusive: if you specify a value for both, only the `glob` value is used. + + For example, to change `coolapp/__init__.py` with the defaults and alter `CHANGELOG.md` twice: + + ```toml + [[tool.bumpversion.files]] + filename = "coolapp/__init__.py" + + [[tool.bumpversion.files]] + filename = "CHANGELOG.md" + search = "Unreleased" + + [[tool.bumpversion.files]] + filename = "CHANGELOG.md" + search = "{current_version}...HEAD" + replace = "{current_version}...{new_version}" + ``` + +=== "CFG" + + INI-style configuration is in the section: `[bumpversion:file:]` or `[bumpversion:glob:]`. + + Both, `file:` and `glob:` are configured the same. Their difference is that file will match file names directly like `requirements.txt`. While glob also matches multiple files via wildcards like `**/pom.xml`. + + !!! note + + The configuration file format requires each section header to be unique. If you want to process a certain file multiple times, you may append a description between parens to the `file` keyword: `[bumpversion:file (special one):…]`. + + + + For example, to change `coolapp/__init__.py` with the defaults and alter `CHANGELOG.md` twice: + + ```ini + [bumpversion:file:coolapp/__init__.py] + + [bumpversion:file(version heading):CHANGELOG.md] + search = Unreleased + + [bumpversion:file(previous version):CHANGELOG.md] + search = {current_version}...HEAD + replace = {current_version}...{new_version} + ``` diff --git a/docs/reference/configuration/global.md b/docs/reference/configuration/global.md new file mode 100644 index 00000000..1e90d48a --- /dev/null +++ b/docs/reference/configuration/global.md @@ -0,0 +1,416 @@ +--- +title: Global Configuration +description: Configuration values that affect all of Bump My Version +icon: +date: 2024-08-11 +comments: true +--- +# Global Configuration + +The general configuration is grouped in a `[tool.bumpversion]` or `[bumpversion]` section, depending on if it is a TOML or INI file, respectfully. + +## allow_dirty + +::: field-list + required + : No + + default + : `False` + + type + : boolean + + command line option + : `--allow-dirty | --no-allow-dirty` + + environment var + : `BUMPVERSION_ALLOW_DIRTY` + + +Bump-my-version's default behavior is to abort if the working directory has uncommitted changes. This protects you from releasing unversioned files and overwriting unsaved changes. + +## commit + +::: field-list + required + : No + + default + : `False` (Don't create a commit) + + type + : boolean + + command line option + : `--commit | --no-commit` + + environment var + : `BUMPVERSION_COMMIT` + +Whether to create a commit using git or Mercurial. + +If you have pre-commit hooks, add an option to [`commit_args`](global.md#commit_args) to turn off your pre-commit hooks. For Git, use `--no-verify` and use `--config hooks.pre-commit=` for Mercurial. + +## commit_args + +::: field-list + + required + : No + + default + : `""` + + type + : string + + command line option + : `--commit-args` + + environment var + : `BUMPVERSION_COMMIT_ARGS` + +Extra arguments to pass to commit command. This is only used when the [`commit`](global.md#commit) option is set to `True`. + +If you have pre-commit hooks, add an option to turn off your pre-commit hooks. For Git, use `--no-verify` and use `--config hooks.pre-commit=` for Mercurial. + +## current_version + +::: field-list + + required + : **Yes** + + default + : `""` + + type + : string + + command line option + : `--current-version` + + environment var + : `BUMPVERSION_CURRENT_VERSION` + +The current version of the software package before bumping. A value for this is required. + +## ignore_missing_files + +::: field-list + + required + : No + + default + : `False` + + type + : boolean + + command line option + : `--ignore-missing-files` + + environment var + : `BUMPVERSION_IGNORE_MISSING_FILES` + +If `True`, don't fail if the configured file is missing. + +## ignore_missing_version + +::: field-list + required + : No + + default + : `False` + + type + : boolean + + command line option + : `--ignore-missing-version` + + environment var + : `BUMPVERSION_IGNORE_MISSING_VERSION` + +If `True`, don't fail if the version string to be replaced is not found in the file. + +## message + +::: field-list + + required + : No + + default + : `Bump version: {current_version} → {new_version}` + + type + : string + + command line option + : `--message` + + environment var + : `BUMPVERSION_MESSAGE` + +The commit message template to use when creating a commit. This is only used when the [`commit`](global.md#commit) option is set to `True`. + +This string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](../formatting-context.md) describes the available variables. + +## parse + +::: field-list + required + : No + + default + : `(?P\d+)\.(?P\d+)\.(?P\d+)` + + type + : string + + command line option + : `--parse` + + environment var + : `BUMPVERSION_PARSE` + +This is the default regular expression ([Python regular expression syntax](https://docs.python.org/3/library/re.html#regular-expression-syntax)) for finding and parsing the version string into its components. Individual part or file configurations may override this. + +The regular expression must be able to parse all strings produced by the configured [`serialize`](global.md#serialize) value. Named matching groups ("`(?P...)`") indicate the version part the matched value belongs to. + +## regex + +::: field-list + + required + : No + + default + : `False` + + type + : boolean + + command line option + : `--regex | --no-regex` + + environment var + : `BUMPVERSION_REGEX` + +Treat the `search` string as a regular expression. + +## replace + +::: field-list + required + : No + + default + : `{new_version}` + + type + : string + + command line option + : `--replace` + + environment var + : `BUMPVERSION_REPLACE` + +This is the template to create the string that will replace the current version number in the file. + +## search + +::: field-list + required + : No + + default + : `{current_version}` + + type + : string + + command line option + : `--search` + + environment var + : `BUMPVERSION_SEARCH` + +This is the template string for searching. It is rendered using the [formatting context](../formatting-context.md) for searching in the file. Individual file configurations may override this. This can span multiple lines and is templated using [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](../formatting-context.md) describes the available variables. + +This is useful if there is the remotest possibility that the current version number might be present multiple times in the file and you mean to bump only one of the occurrences. + +## serialize + +::: field-list + required + : No + + default + : `["{major}.{minor}.{patch}"]` + + type + : an array of strings + + command line option + : `--serialize` + + environment var + : `BUMPVERSION_SERIALIZE` + +This is the default list of templates specifying how to serialize the version parts back to a version string. Individual part or file configurations may override this. + +Since version parts can be optional, bumpversion will try the serialization formats beginning with the first and choose the last one where all values can all non-optional values are represented. + +In this example (in TOML): + +```toml +serialize = [ + "{major}.{minor}.{patch}", + "{major}.{minor}", + "{major}" +] +``` + +Since `0` is optional by default, Version `1.8.9` will serialize to `1.8.9`, `1.9.0` will serialize to `1.9`, and version `2.0.0` will serialize as `2`. + +Each string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](../formatting-context.md) describes the available variables. + +## sign_tags + +::: field-list + + required + : No + + default + : `False` (Don't sign tags) + + type + : boolean + + command line option + : `--sign-tags | --no-sign-tags` + + environment var + : `BUMPVERSION_SIGN_TAGS` + +If `True`, sign the created tag, when [`tag`](global.md#tag) is `True`. + +## tag + +::: field-list + + required + : No + + default + : `False` (Don't create a tag) + + type + : boolean + + command line option + : `--tag | --no-tag` + + environment var + : `BUMPVERSION_TAG` + +If `True`, create a tag after committing the changes. The tag is named using the [`tag_name`](global.md#tag_name) option. + +If you are using `git`, don't forget to `git-push` with the `--tags` flag when you are done. + +## tag_message + +::: field-list + required + : No + + default + : `Bump version: {current_version} → {new_version}` + + type + : string + + command line option + : `--tag-message` + + environment var + : `BUMPVERSION_TAG_MESSAGE` + +The tag message template to use when creating a tag when [`tag`](global.md#tag) is `True` + +This string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](../formatting-context.md) describes the available variables. + +Bump My Version creates an *annotated* tag in Git by default. To turn this off and create a *lightweight* tag, you must explicitly set an empty `tag_message` value. + +## tag_name + +::: field-list + + required + : No + + default + : `v{new_version}` + + type + : string + + command line option + : `--tag-name` + + environment var + : `BUMPVERSION_TAG_NAME` + +The template used to render the tag when [`tag`](global.md#tag) is `True`. + +This string is templated using the [Python Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax). The [formatting context reference](../formatting-context.md) describes the available variables. + +## Examples + +=== "TOML" + + ```toml + [tool.bumpversion] + allow_dirty = false + commit = false + message = "Bump version: {current_version} → {new_version}" + commit_args = "" + tag = false + sign_tags = false + tag_name = "v{new_version}" + tag_message = "Bump version: {current_version} → {new_version}" + current_version = "1.0.0" + parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" + serialize = [ + "{major}.{minor}.{patch}" + ] + search = "{current_version}" + replace = "{new_version}" + ``` + +=== "CFG" + + ```ini + [bumpversion] + allow_dirty = False + commit = False + message = Bump version: {current_version} → {new_version} + commit_args = + tag = False + sign_tags = False + tag_name = v{new_version} + tag_message = Bump version: {current_version} → {new_version} + current_version = 1.0.0 + parse = (?P\d+)\.(?P\d+)\.(?P\d+) + serialize = + {major}.{minor}.{patch} + search = {current_version} + replace = {new_version} + ``` diff --git a/docs/reference/configuration/index.md b/docs/reference/configuration/index.md new file mode 100644 index 00000000..d7469840 --- /dev/null +++ b/docs/reference/configuration/index.md @@ -0,0 +1,37 @@ +--- +title: Configuration +description: How to configure Bump My Version +icon: +date: 2024-08-11 +comments: true +--- +# Configuration + +Bump My Version looks in three places for configuration information (in order of precedence): + +1. command line +2. configuration file +3. environment variables + + +## Configuration files + +Bump My Version looks in four places for the configuration file to parse (in order of precedence): + +1. `--config-file ` _(command line argument)_ +2. `BUMPVERSION_CONFIG_FILE=file` _(environment variable)_ +3. `.bumpversion.cfg` _(legacy)_ +4. `.bumpversion.toml` +5. `setup.cfg` _(legacy)_ +6. `pyproject.toml` + +`.toml` files are recommended. We will likely drop support for `ini`-style formats in the future. You should add your configuration file to your source code management system. + +By using a configuration file, you no longer need to specify those options on the command line. The configuration file also allows greater flexibility in specifying how files are modified. + + +## Configuration sections + +- [Global](global.md) +- [Version Component](version-component.md) +- [File](file.md) diff --git a/docs/reference/configuration/version-component.md b/docs/reference/configuration/version-component.md new file mode 100644 index 00000000..549b0a07 --- /dev/null +++ b/docs/reference/configuration/version-component.md @@ -0,0 +1,133 @@ +--- +title: Version part configuration +description: Configuration options for a specific version part +icon: +date: 2024-08-11 +comments: true +--- +# Version component-specific configuration + +Version component configuration is grouped in a `[tool.bumpversion.parts.]` or `[bumpversion:part:]` section, depending on if it is a TOML or INI file, respectfully. + +You only need to configure version parts if they deviate from the default, and then you only need to specify the overridden options. + +## values + +::: field-list + required + : No + + default + : numeric (i.e. `0`, `1`, `2`, …) + + type + : array of strings + +An explicit list of all values to iterate through when bumping this part. An empty array is treated as indicating `numeric` values. + +## optional_value + +::: field-list + required + : No + + default + : The first entry in `values`, `0` when using numeric values + + type + : string + +When the version part matches this value, it is considered optional when serializing the final version string. + +!!! note + + Numeric values are still treated as strings internally, so when specifying an optional value, you must use a string. + + +## first_value + +::: field-list + required + : No + + default + : The first entry in `values`, `0` when using numeric values + + type + : string + +When the part is reset, the value will be set to the value specified here. + +!!! note + + Numeric values are still treated as strings internally, so when specifying a first value, you must use a string. + + +## independent + +::: field-list + required + : No + + default + : `False` + + type + : boolean + +When this value is set to `True`, the part is not reset when other parts are incremented. Its incrementation is +independent of the other parts. It is useful when you have a build number in your version that is incremented independently of the actual version. + +## always_increment + +::: field-list + required + : No + + default + : `False` (`True` if `calver_format` is set) + + type + : boolean + +When this value is set to `True`, the part is always incremented when the version is bumped, regardless of the target part. + + +## calver_format + +::: field-list + required + : No + + default + : empty + + type + : string + +The `calver_format` is a string that specifies the format of the version part. It is used to determine the next value when bumping the version. The format is a string that uses the placeholders defined in the [CalVer reference](../calver_reference.md#calendar-versioning-codes). + +## Examples + +=== "TOML" + + ```toml + [tool.bumpversion.parts.release] + values = [ + "alpha", + "beta", + "gamma" + ] + optional_value = "gamma" + ``` + +=== "CFG" + + ```ini + [bumpversion:part:release] + optional_value = gamma + values = + alpha + beta + gamma + ``` diff --git a/docs/reference/formatting-context.md b/docs/reference/formatting-context.md index 345fe0c9..5edb5dd0 100644 --- a/docs/reference/formatting-context.md +++ b/docs/reference/formatting-context.md @@ -58,22 +58,22 @@ These fields will only have values if the code is in a Git or Mercurial reposito `current_version` : The current version serialized as a string - `current_` - : Each version part defined by the [version configuration parsing regular expression](version-parts.md#version-configuration). The default configuration would have `current_major`, `current_minor`, and `current_patch` available. + `current_` + : Each version component defined by the [version configuration parsing regular expression](configuration/global.md#parse). The default configuration would have `current_major`, `current_minor`, and `current_patch` available. `new_version` : The new version serialized as a string - `new_` - : Each version part defined by the [version configuration parsing regular expression](version-parts.md#version-configuration). The default configuration would have `new_major`, `new_minor`, and `new_patch` available. + `new_` + : Each version component defined by the [version configuration parsing regular expression](configuration/global.md#parse). The default configuration would have `new_major`, `new_minor`, and `new_patch` available. !!! note The following fields are only available when serializing a version. ::: field-list - `` - : Each version part defined by the [version configuration parsing regular expression](version-parts.md#version-configuration). The default configuration would have `major`, `minor`, and `patch` available. + `` + : Each version part defined by the [version configuration parsing regular expression](configuration/global.md#parse). The default configuration would have `major`, `minor`, and `patch` available. ## Environment variables diff --git a/docs/reference/index.md b/docs/reference/nav.md similarity index 56% rename from docs/reference/index.md rename to docs/reference/nav.md index 086c4f99..d1ed3da7 100644 --- a/docs/reference/index.md +++ b/docs/reference/nav.md @@ -1,10 +1,6 @@ -# Reference - -- [Subcommands](subcommands/index.md) - [Command-line interface](cli.md) -- [Configuration](configuration.md) +- [Configuration](configuration/) - [Calendar versioning reference](calver_reference.md) - [Formatting context](formatting-context.md) -- [Version parts](version-parts.md) - [Search and replace configuration](search-and-replace-config.md) -- [API](api/bumpversion/index.md) +- [API](api/) diff --git a/docs/reference/subcommands/index.md b/docs/reference/subcommands/index.md deleted file mode 100644 index ec7b3f28..00000000 --- a/docs/reference/subcommands/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Subcommand reference - -Bump-my-version uses subcommands to focus its functionality. - -- `bump` triggers the version incrementing workflow -- `replace` replaces the version in files without triggering a version increment. -- `sample-config` helps new users configure bumpy-my-version by printing a sample configuration file. -- `show` provides access to current configuration information. -- `show-bump` helps developers understand the current versioning convention by showing the possible versions resulting from the `bump` subcommand. diff --git a/docs/tutorials/getting-started.md b/docs/tutorials/getting-started.md new file mode 100644 index 00000000..e687fa9e --- /dev/null +++ b/docs/tutorials/getting-started.md @@ -0,0 +1,146 @@ +# Getting Started + +## Installation + +You can download and install the latest version of this software from the Python package index (PyPI) as follows: + +```console +pip install --upgrade bump-my-version +``` + +## Create a default configuration + +The default configuration uses a simplified version of [semantic versioning](https://semver.org/). + +!!! Note + + Python projects can use `pyproject.toml` as the `--destination` of the sample config. + +```console title="Generating a default configuration" +$ bump-my-version sample-config --no-prompt --destination .bumpversion.toml +$ cat .bumpversion.toml +[tool.bumpversion] +current_version = "0.1.0" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" +serialize = ["{major}.{minor}.{patch}"] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +tag = false +sign_tags = false +tag_name = "v{new_version}" +tag_message = "Bump version: {current_version} → {new_version}" +allow_dirty = false +commit = false +message = "Bump version: {current_version} → {new_version}" +commit_args = "" +``` + +## Visualize the versioning path + +You can see the potential versioning paths with the `show-bump` subcommand. This visualization will help debug any versioning logic you implement. + +```console title="Showing the potential versioning path" +$ bump-my-version show-bump +0.1.0 ── bump ─┬─ major ─ 1.0.0 + ├─ minor ─ 0.2.0 + ╰─ patch ─ 0.1.1 +``` + +You can also pass in a specific version to see how bumping that version would work. + +```console title="Showing the potential versioning path from a specific version" +$ bump-my-version show-bump 1.2.3 +1.2.3 ── bump ─┬─ major ─ 2.0.0 + ├─ minor ─ 1.3.0 + ╰─ patch ─ 1.2.4 +``` + + +## Configure a file to modify when bumping + +Let's say your version is stored in a file named `VERSION`. Every time you bump your version, that file needs to change. + +Create the `VERSION` file with the current version `0.1.0`: + +```console title="Create a VERSION file" +$ echo "0.1.0" >> VERSION +``` + +Add the following to the `.bumpversion.toml` file. + +```toml title=".bumpversion.toml" +[[tool.bumpversion.files]] +filename = "VERSION" +``` + +Now bump-my-version will look in the `VERSION` file for the current version in that file and replace it with the new version on each `bump-my-version bump` command. + +## Seeing what would happen with dry-run + +You will increment the version using the `bump` subcommand. You "bump" a specific segment of the version. These segments are defined in the `parse` configuration. In this configuration (`(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)`) the segments are `major`, `minor`, `patch`. + +The `--dry-run` option will explain all the steps it performs without permanent changes. Use the `-vv` option to get the full description for debugging later. + +!!! Note + + If you are in a Git or Mercurial repository, you may see additional messages. + +```console title="Incrementing the minor segment" +$ bump-my-version bump minor --dry-run -vv +Starting BumpVersion 0.25.1 +Reading configuration + Reading config file: /users/gettingstarted/.bumpversion.toml + Parsing current version '0.1.0' + Parsing version '0.1.0' using regexp '(?P\d+)\.(?P\d+)\.(?P\d+)' + Parsed the following values: major=0, minor=1, patch=0 + Attempting to increment part 'minor' + Values are now: major=0, minor=2, patch=0 + Serializing version '' + Using serialization format '{major}.{minor}.{patch}' + Serialized to '0.2.0' + New version will be '0.2.0' +Dry run active, won't touch any files. + +File VERSION: replace `{current_version}` with `{new_version}` + Serializing the current version + Serializing version '' + Using serialization format '{major}.{minor}.{patch}' + Serialized to '0.1.0' + Serializing the new version + Serializing version '' + Using serialization format '{major}.{minor}.{patch}' + Serialized to '0.2.0' + Rendering search pattern with context + No RegEx flag detected. Searching for the default pattern: '0\.1\.0' + Found '0\.1\.0' at line 1: 0.1.0 + Would change file VERSION: + *** before VERSION + --- after VERSION + *************** + *** 1 **** + ! 0.1.0 + --- 1 ---- + ! 0.2.0 + +Processing config file: /users/gettingstarted/.bumpversion.toml + Serializing version '' + Using serialization format '{major}.{minor}.{patch}' + Serialized to '0.1.0' + Serializing version '' + Using serialization format '{major}.{minor}.{patch}' + Serialized to '0.2.0' + Rendering search pattern with context + No RegEx flag detected. Searching for the default pattern: '0\.1\.0' + Found '0\.1\.0' at line 1: 0.1.0 + Would change file /users/gettingstarted/.bumpversion.toml:tool.bumpversion.current_version: + *** before /users/gettingstarted/.bumpversion.toml:tool.bumpversion.current_version + --- after /users/gettingstarted/.bumpversion.toml:tool.bumpversion.current_version + *************** + *** 1 **** + ! 0.1.0 + --- 1 ---- + ! 0.2.0 +Done. +``` diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md deleted file mode 100644 index 4978d42d..00000000 --- a/docs/tutorials/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tutorials - - -- [Versioning using semantic versioning](semantic-versioning-example.md) -- [Basic usage](usage.md) diff --git a/docs/tutorials/nav.md b/docs/tutorials/nav.md new file mode 100644 index 00000000..5463892c --- /dev/null +++ b/docs/tutorials/nav.md @@ -0,0 +1,2 @@ +- [Getting Started](getting-started.md) +- [Semantic Versioning](semantic-versioning-example.md) diff --git a/docs/tutorials/usage.md b/docs/tutorials/usage.md deleted file mode 100644 index c906d949..00000000 --- a/docs/tutorials/usage.md +++ /dev/null @@ -1,115 +0,0 @@ -# Usage - -There are two modes of operation: On the command line for single-file operation and using a configuration file (`pyproject.toml` or `.bumpversion.toml`) for more complex multi-file processes. We recommend using a configuration file for all but the simplest of projects. - -!!! Warning - - The invocation of `bump-my-version` changed in version 0.6.0. It splits functionality into sub-commands. It remains backward-compatible with previous versions. Previous usage is discouraged and may be removed in a 1.0 release. - -## Incrementing a version - -```console -bump-my-version bump [OPTIONS] [ARGS]... -``` - -The `bump` sub-command triggers a version increment. The [complete list of options](../reference/cli.md#bump-my-version-bump) is available. The `ARGS` may contain a `VERSION_PART` or `FILES` - - -### `VERSION_PART` - -_**[optional]**_ - -The part of the version to increase, e.g., `minor`. - -Valid values include those given in the [`--serialize`](../reference/configuration.md#serialize) / [`--parse`](../reference/configuration.md#parse) option. - -For example, if the current version is `0.5.1` and you want to bump it to `0.6.0`: - -```console -bump-my-version bump minor -``` - - -### `FILES` - -_**[optional]**_
-**default**: `None` - -The additional file(s) to modify. - -This file is added to the list of files specified in the configuration file. If you want to rewrite only files specified on the command line, use `--no-configured-files`. - -For example, if the current version is `1.1.9` and you want to bump the version to `2.0.0` and also change the version in the `_version.txt` file: - -```console -bump-my-version bump major _version.txt -``` - -If you want to bump the current version of `1.1.9` to `2.0.0` and _only_ change the `_version.txt` file: - -```console -bump-my-version bump --no-configured-files major _version.txt -``` - -## Showing configuration information - -```console -bump-my-version show [OPTIONS] [ARGS] -``` - -The `show` subcommand allows you to output the entire or parts of the configuration to the console. The default invocation will output in the default format. The default format changes if one or more than one item is requested. If more than one item is asked for, it outputs the result of Python's `pprint` function. If only one thing is asked for, it outputs that value only. - -```console -$ bump-my-version show current_version -1.0.0 -$ bump-my-version show current_version commit -{'current_version': '1.0.0', 'commit': False} -``` - -You can use the `--increment` option to enable a `new_version` key. - -```console -$ bump-my-version show --increment minor current_version new_version -{'current_version': '1.0.0', 'new_version': '1.1.0'} -``` - -You can also specify the output to be in JSON or YAML format: - -```console -$ bump-my-version show --format yaml current_version -current_version: "1.0.0" -$ bump-my-version show --format yaml current_version commit -current_version: "1.0.0" -commit: false -$ bump-my-version show --format json current_version -{ - "current_version": "1.0.0" -} -$ bump-my-version show --format json current_version commit -{ - "current_version": "1.0.0", - "commit": false, -} -``` - -## Searching and replacing without bumping - -More complex workflows may require you to change one or more files without changing the `current_version` in the configuration file. - -The `replace` sub-command works identically to the `bump` sub-command except for the following: - -- It will not commit or tag any changes -- It will not increment the version -- It will not change the configuration file - -!!! NOTE - - If you do not include the `--new-version` option, the `new_version` context variable will be `None`. - - -One way of providing the `--new-version` option is to use the `bump-my-version show` subcommand with an environment variable: - -```console -$ export BUMPVERSION_NEW_VERSION=$(bump-my-version show new_version --increment ) -$ bump-my-version replace -``` diff --git a/mkdocs.yml b/mkdocs.yml index 1267be10..2168ab9e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,15 +10,15 @@ theme: logo: assets/bump-my-version-logo.svg favicon: assets/favicon.png features: - - navigation.tabs - navigation.sections - navigation.path - navigation.indexes - - toc.integrate + - navigation.top - content.action.edit - content.action.view - content.code.annotate - content.tabs.link + - toc.integrate palette: - media: "(prefers-color-scheme: light)" scheme: default @@ -74,7 +74,7 @@ plugins: - include-markdown - drawio - literate-nav: - nav_file: SUMMARY.md + nav_file: nav.md - gen-files: scripts: - docs/gen_doc_stubs.py @@ -115,9 +115,11 @@ extra_css: - assets/css/cards.css - assets/css/field-list.css -#nav: -# - General: "general/" -# - Provisioning LLMs for Applications: "provisioning-llms/" -# - Tutorials: "tutorials/" -# - Security & Privacy: "security-and-privacy/" -# - Guilds: "guilds/" +nav: + - Home: "index.md" + - Tutorials: "tutorials/" + - How Tos: "howtos/" + - Reference: "reference/" + - Explanation: "explanation/" + - "CHANGELOG.md" + - "CONTRIBUTING.md"