Feature request to support major version, minor version only replacement?
kkweon opened this issue · 12 comments
Often, some files like README shouldn't be updating every full version but only updated when major version is updated (e.g., v1 instead of v1.2.3).
semver package has already a parse function that can be used to parse.
I can contribute, but want to hear thoughts.
Probably the best way would be to extend the semantic-release context object used in the template, splitting the major.minor.patch into the following:
nextRelease.major
nextRelease.minor
nextRelease.patch
enabling __VERSION__ = "v${nextRelease.major}"
similar to what you want.
Would get this for free if it was extended in semantic-release.
Something along the lines of semantic-release/semantic-release#2128.
But, it'd still require some changes in this repo for detection/confirmation, i think?
v1.2.3 -> v1.2.4 is v1 -> v1
v1.2.3 -> v2.0.0 is v1 -> v2
How would you set up?
"results": [
{
"file": "foo/__init__.py",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
or does this still work maybe since it replaced the version (same version to same version)?
And thanks for putting versions in the upstream. That'd be super useful in other plugins.
or does this still work maybe since it replaced the version (same version to same version)?
I think it would still work.
And thanks for putting versions in the upstream.
We'll see if I can figure out the failing tests. 😄
Maybe fresh eyes tomorrow will help!
__VERSION__ = "v${nextRelease.version.split('.')[0]}"
Should get what you want.
Hmm, I'm actually getting error when the major version does not change.
[4:16:47 PM] [semantic-release] › ✖ An error occurred while running semantic-release: Error: Expected match not found!
Error: Error: Expected match not found!
- Expected
+ Received
Array [
Object {
"file": "Dockerfile",
- "hasChanged": false,
+ "hasChanged": true,
"numMatches": 1,
- "numReplacements": 0,
+ "numReplacements": 1,
},
]
- Expected
+ Received
Array [
Object {
"file": "Dockerfile",
- "hasChanged": false,
+ "hasChanged": true,
"numMatches": 1,
- "numReplacements": 0,
+ "numReplacements": 1,
},
]
at /home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/@google/semantic-release-replace-plugin/dist/index.js:98:35
at step (/home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/@google/semantic-release-replace-plugin/dist/index.js:59:23)
at Object.next (/home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/@google/semantic-release-replace-plugin/dist/index.js:40:53)
at fulfilled (/home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/@google/semantic-release-replace-plugin/dist/index.js:31:58) {
pluginName: '@google/semantic-release-replace-plugin'
}
probably need to remove the results from your config as it will depend on the version.
doesn't that mean no validation?
After removing the config, I'm still getting the error.
[5:31:47 PM] [semantic-release] › ✖ An error occurred while running semantic-release: Error: Expected match not found!
Error: Error: Expected match not found!
- Expected
+ Received
Array [
Object {
"file": "Dockerfile",
- "hasChanged": false,
"numMatches": 1,
- "numReplacements": 0,
},
]
- Expected
+ Received
Array [
Object {
"file": "Dockerfile",
- "hasChanged": false,
"numMatches": 1,
- "numReplacements": 0,
},
]
Removing the "results" field completely was successful, now I guess there's no validation then.