The semantic-release-replace-plugin
plugin provides functionality to update version strings throughout a project. This enables semantic release to be used in many different languages and build processes.
Read more about Semantic Release.
$ npm install https://github.com/centralnicgroup-opensource/semantic-release-replace-plugin -D
The following example uses this plugin to demonstrate using semantic-release in a Python package where __VERSION__
is defined in the root __init__.py
file.
{
"plugins": [
"@semantic-release/commit-analyzer",
[
"semantic-release-replace-plugin",
{
"replacements": [
{
"files": ["foo/**.py"],
"from": "__VERSION__ = \".*\"",
"to": "__VERSION__ = \"${nextRelease.version}\"",
"ignore" ["foo/go.py"],
"results": [
{
"file": "foo/__init__.py",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
}
]
}
],
[
"@semantic-release/git",
{
"assets": ["foo/*.py"]
}
]
]
}
The presence of the results
array will trigger validation that a replacement has been made. This is optional but recommended.
This plugin will not commit changes unless you specify assets for the @semantic-release/git plugin! This is highlighted below.
[
"@semantic-release/git",
{
"assets": ["foo/*.py"]
}
]
Please refer to the documentation for more options.