semantic-release-replace-plugin
semantic-release-replace-plugin copied to clipboard
use regex matches in `to` replacement
How can I use regex match groups and reference them in the to config?
Example
services:
app:
image: namespace/project:1.0.0
command: "run-server"
db:
image: postgres:17.5
module.exports = {
branches: ["main"],
plugins: [
// ...
[
"semantic-release-replace-plugin",
{
replacements: [
{
files: ["docker-compose.yml"],
from: '^(?<ident>\s*)image:\s*(?<registry>.*)?(?<image>namespace\/project):(.*)\s*$',
to: '${ident}image: ${registry}${image}:${nextRelease.version}',
results: [
{
file: "pyproject.toml",
hasChanged: true,
numMatches: 1,
numReplacements: 1,
},
],
countMatches: true,
},
],
},
],
// ...
],
};
Expected for 1.0.0 to 1.1.0
services:
app:
image: namespace/project:1.1.0
command: "run-server"
db:
image: postgres:17.5