Renovate: update dependency with syntactically different semver tags

195 views Asked by At

This is my first time setting something up with Renovate, so bear in mind I may be missing or misunderstanding some concepts.

I have been following https://joht.github.io/johtizen/automation/2022/08/03/keep-your-cpp-dependencies-up-to-date.html to integrate Renovate and CPM with a C++/CMake repo. As a first test, I've swapped out a dependency we had simply pasted verbatim into the repo, to see if Renovate can parse the relevant package lock file and recommend an update for this dependency.

The entry for this dependency is as follows:

CPMDeclarePackage(StandaloneASIO_Package
  NAME StandaloneASIO_Package
  VERSION 1.21.0
  GIT_TAG asio-1-21-0
  GIT_REPOSITORY https://github.com/chriskohlhoff/asio
)

So far, I have managed to get Renovate to correctly parse the current version from this entry:

"customManagers": [
    {
        "customType": "regex",
        "fileMatch": [
            "(^|/)package-lock\\.cmake$"
        ],
        "matchStrings": [
            "CPMDeclarePackage\\s*\\(\\s*[\\s\\w\\W]*\\s+VERSION\\s*\"?(?<currentValue>[\\w\\.]+)\"?\\s+[\\s\\w\\W]*\\s+GIT_REPOSITORY\\s+\"?(?<depName>.*?[^0-9a-f\\s]+.*|.{1,4}?)\"?",
            "CPMDeclarePackage\\s*\\(\\s*[\\s\\w\\W]*\\s+GIT_REPOSITORY\\s+\"?\\s+(?<depName>.*?[^0-9a-f\\s]+.*|.{1,4}?)\"?[\\s\\w\\W]*\\s+VERSION\\s*\"?(?<currentValue>[\\w\\.]+)\"?"
        ],
        "datasourceTemplate": "github-tags"
    }
]

However, this is where I get stuck. The Renovate dashboard still raises the error: Renovate failed to look up the following dependencies: Failed to look up github-tags package https://github.com/chriskohlhoff/asio.

My assumption was that since this repo uses tags rather than releases to record new versions, and lives on GitHub, that the correct data source should be github-tags, but obviously this is not working. Unfortunately Renovate's documentation on the github-tags data source lacks any useful information, so I have no idea how it is supposed to be used.

My first suspicion is that the tags use the format asio-<major>-<minor>-<patch> rather than the standard semver v<major>.<minor>.<patch>, so Renovate may be unable to parse any meaning from them. Perhaps there is a way to define a template for parsing the tags that would allow Renovate to understand them, but the only documentation I've come across is regarding creating a whole new data source. I feel like this is probably overkill for what I need to do, and am having trouble understanding all of the different elements of that process anyway.

Is there a simple solution for what I need to do here?

1

There are 1 answers

6
Gaël J On

If this is related to the tag, you can try using the extractVersionTemplate configuration.

Something like this:

"extractVersionTemplate": "^asio-(?<version>.*)$"

Note that the template may also contain tokens extracted from matchStrings like:

"extractVersionTemplate": "^{{{depName}}}-(?<version>.*)$"