I have a YAML file with semantic versioning number like this:
version: 1.0.1
I need to increment PATCH part of the version. Is it possible to do it with yq?
UPDATE:
The question is about mikefarah/yq implementation which is installed with brew install yq
.
Please clarify which implementation of yq
you are using. Apart from that, the general approach would be to split the string at the dots, convert the last item to a number and increment it, and then rejoin the array with dots.
Here's one way of doing it using the kislyuk/yq implementation:
.version |= (./"." | last |= tonumber + 1 | join("."))
And here's the same using the mikefarah/yq implementation:
.version |= (split(".") | .[-1] |= ((. tag = "!!int") + 1) | join("."))