gitlabrenovate

How to use Renovate to track custom git tags?


I'm using Renovate to automatically update versions in a Makefile. Specifically, I want to keep the version of OpenLDAP up to date.

In my Makefile, I have a line like: VERSION := 2.5.19

The versions of OpenLDAP are maintained as git tags in their public GitLab repo: https://git.openldap.org/openldap/openldap/-/tags. Tags follow the pattern: OPENLDAP_REL_ENG_2_5_19, OPENLDAP_REL_ENG_2_6_10, etc.

If I manually change my Makefile to: VERSION := OPENLDAP_REL_ENG_2_5_19 and use the following renovate.json config:

{
  "customManagers": [
    {
      "customType": "regex",
      "managerFilePatterns": ["^Makefile$"],
      "matchStrings": [
        "VERSION\\s*:=\\s*(?<currentValue>.*)"
      ],
      "datasourceTemplate": "git-tags",
      "versioningTemplate": "regex:^OPENLDAP_REL_ENG_(\\d+)_(\\d+)_(\\d+)$",
      "depNameTemplate": "https://git.openldap.org/openldap/openldap"
    }
  ]
}

Renovate successfully detects new tags and opens a PR when there is a newer version.

I would like to keep the Makefile simple and only store the semantic version: VERSION := 2.5.19.

Then, I want Renovate to:

So far I have not found a way to make this work with Renovate. When the current value is 2.5.19, Renovate doesn’t seem to recognize that it corresponds to OPENLDAP_REL_ENG_2_5_19.


Solution

  • You would need to create a custom datasource via customDatasources then apply transformTemplates in order perform the necessary replacements

    https://docs.renovatebot.com/configuration-options/#transformtemplates

      "customDatasources": {
        'openldap': {
          "defaultRegistryUrlTemplate": 'https://git.openldap.org/openldap/openldap/-/tags',
          "format": 'html',
          "transformTemplates": [
            "{ \"releases\": releases.{ \"version\": $replace(version, /_/$/, \".\") } }",
          ]
        }
      }
    

    ( Note that the "replacement" statement is not guaranteed to work nor is it tested )

    Then the custom datasource is referenced in the custom manager instead of git-tags

    {
      "customManagers": [
    ...
          "datasourceTemplate": "custom.openldap",
        }
      ]
    }