用于自托管翻新机器人的正则表达式来获取 linuxserver.io 稳定图像

问题描述 投票:0回答:1

我已经设置了翻新自托管机器人。由于 linuxserver.io 有不同的创建 docker 标签的模式,我将切换到正则表达式。

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": [
    "config:base",
    "docker:enableMajor"
  ],
  "packageRules": [
    {
      "packagePatterns": ["^ghcr.io\\/linuxserver\\/"],
      "versionScheme": "regex:MYFANCYREGEX"
    }
  ]
}

但我需要帮助来启动和运行正则表达式。 我使用单元测试和示例创建了一个正则表达式 101 - here

100.200.300
100.200.300.7068-ls170
v100.200.300-ls213
version-100.200.300
version-100.200.300-ls180
version-100.200.300.11111
100.200.300.7068-ls170
nigthly-100.200.300  -> not stable, no match
nightly-100.200.300.3604-ls587  -> not stable, no match
100.200.300-development -> not stable, no match
100.200.300-develop -> not stable, no match
100.200.300-nigthly -> not stable, no match

我无法排除包含某些内容的匹配 -> (?! 或 ^)

我应该如何更改正则表达式以仅获得稳定的版本和图像更新(ls/buildnumbers)

regex versioning regex-negation renovate
1个回答
0
投票

我会使用这个正则表达式(使用 x 标志以提高可读性):

/^

# Should not start with nightly or nigthly (handle misspelling):
(?!nig(?:th|ht)ly)

# Optional compatibility prefix "version-" or "v":
(?<compatibility>[a-z]*-|v)?

# Major, minor and patch numbers:
(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)

# Build information should not contain dev and nightly stuff:
(?!.*(nig(ht|th)ly|develop|development))

# Capture the optional build information:
(?:
  [\.-]?
  (?<build>.*)
)?

$/gmx

在此处更新了您的 regex101 案例研究:https://regex101.com/r/KQZykk/2

如果您无法使用 x 标志,则使用未注释的版本 我在这里添加:https://regex101.com/r/KQZykk/3

PS:为了从带注释的正则表达式传递到未注释的正则表达式,我创建了一个小工具 您可以在这里访问:https://codepen.io/patacra/pen/wvQBxjq

© www.soinside.com 2019 - 2024. All rights reserved.