Renovate: How to remove the "release-" prefix from a version (e.g. release-1.19.2)?

Created on 15 Sep 2020  路  8Comments  路  Source: renovatebot/renovate

Which Renovate are you using?

WhiteSource Renovate App

Which platform are you using?

GitHub.com

Have you checked the logs? Don't forget to include them if relevant

Logs with config file below.

What would you like to do?

I would like to update Nginx version in my versions.yml file using Renovate.

# renovate: datasource=github-releases depName=grafana/grafana
metrics_grafana_version: 7.1.5
# renovate: datasource=github-tags depName=nginx/nginx
metrics_nginx_version: 1.17.10
# renovate: datasource=github-releases depName=prometheus/prometheus
metrics_prometheus_version: 2.21.0
# renovate: datasource=github-releases depName=influxdata/telegraf
metrics_telegraf_version: 1.15.3

I have a problem with Nginx, because Nginx repo has tags in format release-1.19.2.
With my Renovate config:

{
  "extends": ["config:base"],
  "regexManagers": [
    {
      "fileMatch": ["^versions\\.yml$"],
      "matchStrings": [
        "# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)\n.*?: (?<currentValue>.*)"
      ],
      "versioningTemplate": "node"
    }
  ]
}

I got:

DEBUG: Found no results from datasource that look like a version (nginx/nginx)(dependency="nginx/nginx")
{
  "result": {
    "sourceUrl": "https://github.com/nginx/nginx",
    "releases": []
  }
}

When I add packageRules to the config:

"packageRules": [
    {
      "packageNames": ["nginx/nginx"],
      "versioning": "regex:^release-(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)?$"
    }
  ]

I got:

Dependency nginx/nginx has unsupported value 1.17.10
[...]
packageFiles with updates
{
            "depName": "nginx/nginx",
            "currentValue": "1.17.10",
            "datasource": "github-tags",
            "versioning": "node",
            "replaceString": "# renovate: datasource=github-tags depName=nginx/nginx\nmetrics_nginx_version: 1.17.10",
            "depIndex": 1,
            "updates": [],
            "warnings": [],
            "skipReason": "unsupported-value"
          },

And with:

"packageRules": [
    {
      "packageNames": ["nginx/nginx"],
      "versioning": "regex:(release-)?(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)?"
    }
  ]

I got:

packageFiles with updates
[...]

            "depName": "nginx/nginx",
            "currentValue": "1.17.10",
            "datasource": "github-tags",
            "versioning": "node",
            "replaceString": "# renovate: datasource=github-tags depName=nginx/nginx\nmetrics_nginx_version: 1.17.10",
            "depIndex": 1,
            "updates": [
              {
                "fromVersion": "1.17.10",
                "toVersion": "release-1.19.2",
                "newValue": "release-1.19.2",
                "newMajor": 1,
                "newMinor": 19,
                "updateType": "minor",
                "isSingleVersion": true
              }
            ],
            "warnings": [],
            "fixedVersion": "1.17.10",
            "sourceUrl": "https://github.com/nginx/nginx"
          },

and a PR, which updates the versions file to:

metrics_nginx_version: release-1.19.2

My original repo is https://github.com/platan/metrics-shields-io-config, but I use a fork for tests.

I would like to update my file to:

metrics_nginx_version: 1.19.2
priority-3-normal feature

All 8 comments

I've transferred this into the main repo as I don't think it's possible without a feature being added.

@platan as workaround you can use nginx docker image and docker versioning.

@viceice I've had some ideas on this. Tell me what do you think?

A very simple feature like stripVersionPrefix with a string value could solve this and most other similar problems (e.g. leading v). But then what if it's a suffix?

An alternative could be to name it something like extractVersion and use a named regex group e.g. "extractVersion": "release-(?.)" but it wouldn't let you *add any text if necessary.

Wondering instead about a more configurable option like transformVersion that could take a regex match as first param and a replace as second. e.g. "release-", and "".

Alternatively another approach could be to use named capture groups to match but handlebars to transform.

My best idea right now:

  • Go with extractVersion for now and have it require a named capture group version
  • In future, add an additional transformVersion option that lets you use/compose any captured groups in a handlebars template, like {{version}}.0

BTW I think a more flexible compatibility capability for versions could be wrapped into this functionality. e.g. instead of dockerver it could be something like "extractVersion": "^(?<version>[^-]*)(-*(?<compatibility>.*))?$": https://regex101.com/r/1WNLHr/2

Like it. Add this to package rules?

Yes, it would be configurable in packageRules although not necessarily exclusive to them, e.g. people might configure them within an object. I was also thinking whether there'd be a performance hit if we default its value to "extractVersion": "^(?<version>.*)$.

@viceice The workaround with docker datasource + docker versioning + docker image name (nginx instead of nginx/nginx) works! Thanks.

@rarkins I like your idea with extractVersion and transformVersion. We can start with extractVersion.

Can I or anyone else help with implementing this feature or would you like to do it yourself?

@platan if you can create a simple reproduction repo I can fork and test against, then I should be able to implement it pretty fast. It's a small change but you just need to know where to put it.. so best I do it

:tada: This issue has been resolved in version 23.29.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings