attakei / age-cli

Alt bumpversion
https://age.attakei.dev
Apache License 2.0
2 stars 0 forks source link

Support regex replacement #8

Closed attakei closed 6 months ago

attakei commented 6 months ago

Overview

Currently, release-body.md is managed by age itself. (This is used on GitHub Releases)

release-body.md includes diff URL about current_version and new_version, but it cannot replace by age.

Settings (from here):

[[files]]
path = ".github/release-body.md"
search = "- Changelog is https://github.com/attakei/age-cli/blob/v{{current_version}}/CHANGELOG.md"
replace = "- Changelog is https://github.com/attakei/age-cli/blob/v{{new_version}}/CHANGELOG.md"

Output (from here:

Release updated `age` as built binary.

- Changelog is https://github.com/attakei/age-cli/blob/v0.6.0/CHANGELOG.md
- Source changes is https://github.com/attakei/age-cli/compare/v0.5.0...v0.6.0

Source changes have not also curren_version but old_version when running age-cli. CLI cannot know what is previous version.

Fix approach

Use regexp

Example:

[[files]]
path = ".github/release-body.md"
search = """
- Changelog is https://github.com/attakei/age-cli/blob/v{{current_version}}/CHANGELOG.md
- Source changes is (.+)
""""
replace = """
- Changelog is https://github.com/attakei/age-cli/blob/v{{new_version}}/CHANGELOG.md
- Source changes is https://github.com/attakei/age-cli/compare/v{{current_version}}...v{{new_version}}
"""

search has syntax of regexp. If it includes regexp, writer use it instead of simple matching to search target.

attakei commented 6 months ago

Reelased by v0.8.0