- Sat 21 October 2023
- programming
- Gaige B. Paulsen
- #programming, #renovate
I've been very happy using Renovate (the free version) for use on my personal projects. I've previously discussed running it on one of my k8s clusters.
Today, I was trying to deal with a very specific problem: I needed to track a dependency via git tags, instead of tracking the head of the main branch.
Originally, I expected I'd be able to just set the branch in the
.gitmodules
file and then it's do "the right thing." Turns out,
not so much.
I tried a number of ways to leverage the default configuration, but couldn't get that working. So, I decided to take matters into my own hands and use a custom config.
Since my usual config enables git-submodules
, I need to disable it
in for my custom manager to work.
"git-submodules": { "enabled": false },
"customManagers": [
{
"customType": "regex",
"fileMatch": [ "(^|/)\\.gitmodules$" ],
"datasourceTemplate": "git-tags",
"matchStrings": [
"url = (?<depName>.*?)#(?<currentValue>.*?)\\s"
],
"versioningTemplate": "semver",
"depTypeTemplate": "dependencies"
}
]
For those who haven't dealt with the customManagers
before, they're
very powerful. Basically, you can use RegEx to extract data from the
file and describe exactly which datasource
, versioning
and more
you want applied.
In this case, I'm pulling the url
and looking for a #
to indicate
the tag. Originally, I used the standard branch
mechanism, but for some
reason, the result of the first application of the branch
version
resulted in the URL with the #
marker.
Previously, I'd used this in some of my docker files, based on the
regexManager
, which honestly is basically the same thing. I'm not sure
why there are two ways to do this, nor why both are in the documentation,
but the other place I've done this is:
"regexManagers": [
{
"fileMatch": ["(^|/)Chart\\.yaml$"],
"matchStrings": [
"#\\s?renovate: image=(?<depName>.*?)\\s?appVersion:\\s?\\\"?(?<currentValue>[\\w+\\.\\-]*)"
],
"datasourceTemplate": "docker"
}
]
And I also used it in Renovating Ansible where I used it to update based on a gitlab tag, but in an explicit manner, not as part of a git submodule.
The key difference here appears to be the manager name (and differences in how I ran the tests).