c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Feature Request: Custom actions instruction file (appending to files) #208

Closed den4uk closed 3 years ago

den4uk commented 3 years ago

Here is the scenario:

# bumpversion.yml
# a simple example
part: PATCH
file_edit:
    changelog:
        file_name: ./CHANGELOG.md
        action: APPEND
        text: "This fixes bug foo bar"
autoclear: true

a yaml file was only used for demonstration purposes.

This would be a useful when multiple people are working on the same repository, which has very constant push/commit rates. Normally, such results in often merges of the master/main into your feature branch due to the merge conflicts in version and changelog files. Having a file describing extra activities to perform can eliminate the need to do this, thus being able to offset these actions to be performed by the CI/CD pipelines instead.

Extended logic of the yaml with explanations:

# bumpversion.yml
# extended example with comments
part: PATCH  # what kind of bump to perform
file_edit:  # any file edits
    changelog:  # name of the edit action
        file_name: ./CHANGELOG.md  # file name where the edit to perform
        action: APPEND  # action on the file (APPEND | OVERWRITE)
        format: "| {new_version} | {date:"%Y-%m-%d"} | {text} |"  # how to format the entry (new_version as now, {date} as datetime.today(), which can also be formatted)
        text: "This fixes bug foo bar"  # value to be written
autoclear: true  # Whether to remove these "dynamic" entries from the file, if `true` - `patch` and `text` are auto-removed from this file, leaving blank spaces on the bumped commit for new instructions to be added

Introducing a workflow of this kind could be a real improvement to many many people.

florisla commented 3 years ago

Hi,

Doing this would be out of scope for bump2version.

There are other tools which can assist in assembling changolog files. Take a look in the file RELATED.md for some pointers.

den4uk commented 3 years ago

Hi @florisla , thanks for getting back.

I took a look at RELATED.md, but the extent of support was rather limited. I understand the request may be out-of scope.

On another thought, is there a way for bump2version to accept 3rd party plugins? It would be nice to be able to extend the functionality, by having pre/post hooks to execute. Of course, the scopes of functionality would fall onto others who write these plugins, but a documented API for achieving this could be even more powerful.

florisla commented 3 years ago

Accepting plugins is a really nice idea, but at this point we lack the manpower to develop and support such infrastructure.

There are lot of details to get right (environment variables, text encoding, error handling, ...) so it's not a small task.

I see bump2version more as a small tool which you can embed in another workflow, e.g. a CI pipeline or a task in pyinvoke. Not the other way around.

florisla commented 3 years ago

Closing this as out of scope.