Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions renovate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Renovate

## CPM package lock

The shared CPM preset reads annotated `package-lock.cmake` files at the repository root or in a
subdirectory. Projects including build-deps, Sunshine, Moonlight-XboxOG, libvirtualhid, and lizardbyte-common
inherit the preset through `local>LizardByte/.github:renovate-config` in `renovate.json`. [CPM preset](cmake.json5).

When adding a lock file to a project, commit it, load it with `CPMUsePackageLock` after including CPM, and call
`CPMGetPackage` with the first argument of `CPMDeclarePackage`. Set `NAME` to the name accepted by `find_package`
when the dependency supports local packages. If a project includes a shared lock file, update the pin in the
repository that owns it. Sunshine includes shared FFmpeg pins this way.
[Sunshine CMake setup](https://github.com/LizardByte/Sunshine/blob/master/CMakeLists.txt).

### Annotation layout

1. Start each dependency block with a comment naming the dependency.
2. Add `# renovate: datasource=... depName=...` directly below it. Use the upstream project for `depName`.
3. For version or tag pins, keep optional keys in the order `packageName`, `versioning`, `extractVersion`, `registryUrl`. Put them on the `# renovate:` line or on consecutive `# key=value` lines.
4. Follow the metadata with `set(NAME_VERSION ...)` or `set(NAME_TAG ...)`, and place `CPMDeclarePackage(...)`
below the tracked assignments.

### GitHub tags

For `github-tags`, Renovate derives `owner/repo` from a literal GitHub HTTPS URL on the `GIT_REPOSITORY` line.
The `.git` suffix is optional. This allows `depName` to identify the upstream project when CPM fetches from a
mirror. An explicit `packageName=owner/repo` takes precedence. When neither is present, including declarations
that use `GITHUB_REPOSITORY` or an archive `URL`, Renovate uses `depName`.
[SVT-AV1 in build-deps](https://github.com/LizardByte/build-deps/blob/master/package-lock.cmake).

Store the full tag in `NAME_TAG`, or use `extractVersion` with a named `version` group to store a version
without the tag prefix. Reconstruct the tag in the declaration when storing only the version.
[SDL in libvirtualhid](https://github.com/LizardByte/libvirtualhid/blob/master/package-lock.cmake).

```cmake
# SDL
# renovate: datasource=github-tags depName=libsdl-org/SDL versioning=semver
# extractVersion=^release-(?<version>\d+\.\d+\.\d+)$
set(SDL3_VERSION 3.4.12)
CPMDeclarePackage(SDL3
NAME SDL3
VERSION ${SDL3_VERSION}
GITHUB_REPOSITORY libsdl-org/SDL
GIT_TAG release-${SDL3_VERSION}
)
```

### Release archives with SHA256 checksums

Use a datasource that can supply the archive digest, such as `github-release-attachments`. Put
`set(NAME_SHA256 ...)` immediately after the version or tag assignment and pass its value to `URL_HASH`.
[Boost in Sunshine](https://github.com/LizardByte/Sunshine/blob/master/package-lock.cmake).

```cmake
# Boost
# renovate: datasource=github-release-attachments depName=boostorg/boost
# versioning=regex:^boost-(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)$
set(BOOST_TAG boost-1.92.0)
set(BOOST_SHA256 9bed76128d4e46755dbe818487788c6fceb6f72b378f4daa49b7e1e600d9088d)
string(REGEX REPLACE "^boost-" "" BOOST_VERSION "${BOOST_TAG}")
CPMDeclarePackage(Boost
NAME Boost
VERSION ${BOOST_VERSION}
URL https://github.com/boostorg/boost/releases/download/${BOOST_TAG}/${BOOST_TAG}-cmake.tar.xz
URL_HASH SHA256=${BOOST_SHA256}
DOWNLOAD_ONLY YES
)
```

### Git branch commits

For `git-refs`, add `# ref=<branch>` after the metadata and set `NAME_COMMIT` to the full 40-character hash.
Renovate uses the full literal URL on the `GIT_REPOSITORY` line of the package declaration. To override it
or supply the URL for a declaration that uses a variable, put `packageName=<git-url>` before `# ref=`.
The build stays pinned to the hash while Renovate follows the branch.
[Moonlight-XboxOG lock file](https://github.com/LizardByte/Moonlight-XboxOG/blob/master/package-lock.cmake),
[build-deps lock file](https://github.com/LizardByte/build-deps/blob/master/package-lock.cmake).

```cmake
# x264
# renovate: datasource=git-refs depName=videolan/x264
# ref=stable
set(X264_COMMIT b35605ace3ddf7c1a5d67a2eb553f034aef41d55)
CPMDeclarePackage(x264
NAME x264
GIT_REPOSITORY https://github.com/LizardByte-infrastructure/x264.git
GIT_TAG ${X264_COMMIT}
DOWNLOAD_ONLY YES
)
```

## Flatpak modules

The shared Flatpak preset reads annotated JSON sources under `packaging/linux/flatpak/modules/`,
including nested modules. Projects inherit it through `local>LizardByte/.github:renovate-config` in
`renovate.json`. [Flatpak preset](flatpak.json5).

### Annotation layout

1. Add an `x-renovate` object to each source Renovate should update. Place it immediately before
`url`.
2. List `datasource` and `depName` first, followed by `packageName` and `versioning` when needed.
Renovate uses `depName` for the lookup unless you supply `packageName`.
3. Keep the fields for the pin together and in order. For Git sources, use `url`, then `tag` or
`branch`, then `commit`. For GitHub release assets, use `url` followed by `sha256`.
4. Keep `x-checker-data` for Flatpak External Data Checker after the pin fields.

For a source maintained through Flatpak External Data Checker, you can record that choice with
`"x-renovate": {"depName": "libtirpc", "enabled": false}`.

### Git tags and branches

Use `github-tags` for a GitHub tag pinned by commit. For a mirrored project, set `depName` to the
upstream name and `packageName` to the mirror's GitHub `owner/repo`. Flatpak checks out the Git
repository specified by `url`.

```json
{
"type": "git",
"x-renovate": {
"datasource": "github-tags",
"depName": "xorg/xserver",
"packageName": "LizardByte-infrastructure/xserver",
"versioning": "regex:^xorg-server-(?<major>[0-9]+)[.](?<minor>[0-9]+)[.](?<patch>[0-9]+)$"
},
"url": "https://github.com/LizardByte-infrastructure/xserver.git",
"tag": "xorg-server-21.1.13",
"commit": "be2767845d6ed3c6dbd25a151051294d0908a995"
}
```

To follow a branch, use `git-refs`, set `packageName` to the full Git URL, use `exact` versioning,
and specify `branch` followed by the pinned `commit`.

### GitHub release assets

Use `github-release-attachments` for an archive or file from a GitHub release. Keep the full tag
in the download URL so Renovate can update the URL and SHA-256 together. Set `versioning` for
nonstandard tags.

```json
{
"type": "archive",
"x-renovate": {
"datasource": "github-release-attachments",
"depName": "boostorg/boost",
"versioning": "regex:^boost-(?<major>[0-9]+)[.](?<minor>[0-9]+)[.](?<patch>[0-9]+)(?<prerelease>[.][A-Za-z0-9.-]+)?$"
},
"url": "https://github.com/boostorg/boost/releases/download/boost-1.92.0/boost-1.92.0-cmake.tar.xz",
"sha256": "9bed76128d4e46755dbe818487788c6fceb6f72b378f4daa49b7e1e600d9088d"
}
```

Use the same `depName` and compatible versioning across sources that track the same dependency.
Renovate can then group matching updates from different architecture assets and the CPM lock
into one pull request.
23 changes: 17 additions & 6 deletions renovate/cmake.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Annotated CPM package lock dependencies",
"customManagers": [
// CPM Package Lock
{
"description": "CPM package lock version and tag pins",
"customType": "regex",
"managerFilePatterns": ["/(^|\/)package-lock.cmake$/"],
"matchStringsStrategy": "recursive",
"matchStrings": [
// Version or tag assignments may be followed by a checksum.
// Read the GitHub repository from the declaration when available.
"# renovate:[^\\r\\n]*(?:\\s*\\r?\\n[ \\t]*#[^\\r\\n]*)*\\s+set\\([A-Za-z0-9_]+_(?:VERSION|TAG)\\s+[^)]+\\)(?:\\s+set\\([A-Za-z0-9_]+_SHA256\\s+[^)]+\\))?(?:\\s+(?:[a-z_][a-z0-9_]*\\([^\\r\\n]*\\)\\s+)*CPMDeclarePackage\\([^)]*?\\r?\\n[ \\t]*GIT_REPOSITORY[ \\t]+\"?https://github\\.com/(?<githubRepository>[A-Za-z0-9-]+/[A-Za-z0-9_.-]+?)(?:\\.git)?/?\"?(?:[ \\t\\r\\n)]|$))?",
// Limit Renovate's replacement to the metadata, version, and optional checksum.
"# renovate: datasource=(?<datasource>[a-zA-Z0-9-._]+?) depName=(?<depName>[^\\s]+?)(?:(?:[ \\t]+|\\s*\\r?\\n#\\s*)packageName=(?<packageName>[^\\s]+?))?(?:(?:[ \\t]+|\\s*\\r?\\n#\\s*)versioning=(?<versioning>[^\\s]+?))?(?:(?:[ \\t]+|\\s*\\r?\\n#\\s*)extractVersion=(?<extractVersion>[^\\s]+?))?(?:(?:[ \\t]+|\\s*\\r?\\n#\\s*)registryUrl=(?<registryUrl>[^\\s]+?))?\\s+set\\([A-Za-z0-9_]+?_(?:VERSION|TAG)\\s+\\\"?(?<currentValue>[^\\\"\\s\\)]+)\\\"?\\s*\\)(?:\\s+set\\([A-Za-z0-9_]+?_SHA256\\s+\"?(?<currentDigest>[a-fA-F0-9]{64})\"?\\s*\\))?",
],
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else if (and (equals datasource 'github-tags') githubRepository)}}{{{githubRepository}}}{{else}}{{{depName}}}{{/if}}",
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{/if}}"
},
{
"description": "CPM package lock commit pins",
"customType": "regex",
"managerFilePatterns": ["/(^|\/)package-lock.cmake$/"],
"matchStrings": [
// Commit pins can supply an explicit URL or use the package declaration.
"# renovate: datasource=(?<datasource>[a-zA-Z0-9-._]+) depName=(?<commitDepName>\\S+)(?:(?:[ \\t]+|\\s*\\r?\\n#\\s*)packageName=(?<packageName>\\S+))?\\s+# ref=(?<currentValue>\\S+)\\s+set\\([A-Za-z0-9_]+_COMMIT\\s+\"?(?<currentDigest>[a-fA-F0-9]{40})\"?\\s*\\)(?:\\s+(?:[a-z_][a-z0-9_]*\\([^\\r\\n]*\\)\\s+)*CPMDeclarePackage\\([^)]*?\\r?\\n[ \\t]*GIT_REPOSITORY[ \\t]+\"?(?<gitRepository>[^\"$\\s()]+)\"?)?",
],
// Skip commit pins without a repository and fall back to the name for tagged dependencies.
"depNameTemplate": "{{#if depName}}{{{depName}}}{{else if packageName}}{{{commitDepName}}}{{else if gitRepository}}{{{commitDepName}}}{{/if}}",
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else if gitRepository}}{{{gitRepository}}}{{else}}{{{depName}}}{{/if}}",
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{/if}}"
// Skip commit pins without a repository.
"depNameTemplate": "{{#if (or packageName gitRepository)}}{{{commitDepName}}}{{/if}}",
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else}}{{{gitRepository}}}{{/if}}"
},
],
}
1 change: 1 addition & 0 deletions renovate/default.json5
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"github>LizardByte/.github//renovate/python.json5",
"github>LizardByte/.github//renovate/readthedocs.json5",
"github>LizardByte/.github//renovate/cmake.json5",
"github>LizardByte/.github//renovate/flatpak.json5",
"github>LizardByte/.github//renovate/jekyll.json5",
],
}
30 changes: 30 additions & 0 deletions renovate/flatpak.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"description": "Flatpak sources annotated with x-renovate",
"customManagers": [
{
"customType": "regex",
"managerFilePatterns": ["packaging/linux/flatpak/modules/**/*.json"],
"matchStringsStrategy": "recursive",
"matchStrings": [
// Put x-renovate immediately before the URL. List datasource, depName, and the optional packageName and versioning in that order.
'"x-renovate"\\s*:\\s*\\{\\s*"datasource"\\s*:\\s*"(?<datasource>[a-z0-9_.-]+)"\\s*,\\s*"depName"\\s*:\\s*"(?<depName>[^"]+)"(?:\\s*,\\s*"packageName"\\s*:\\s*"(?<packageName>[^"]+)")?(?:\\s*,\\s*"versioning"\\s*:\\s*"(?<versioning>[^"]+)")?\\s*\\}\\s*,\\s*"url"\\s*:\\s*"[^"]+"(?:\\s*,\\s*"(?:tag|branch|commit|sha256)"\\s*:\\s*"[^"]+")+',
// Replace the pinned Git ref and commit or the release tag in the download URL and its SHA-256.
'"url"\\s*:\\s*"(?:(?:https://github[.]com/[^/"]+/[^/"]+/releases/download/(?<archiveTag>[^/"]+)/[^"]+)"\\s*,\\s*"sha256"|[^"]+"\\s*,\\s*"(?:tag|branch)"\\s*:\\s*"(?<gitRef>[^"]+)"\\s*,\\s*"commit")\\s*:\\s*"(?<currentDigest>[a-fA-F0-9]{40}(?:[a-fA-F0-9]{24})?)"',
],
"packageNameTemplate": "{{#if packageName}}{{{packageName}}}{{else}}{{{depName}}}{{/if}}",
"versioningTemplate": "{{#if versioning}}{{{replace '(\\x5c){2}' '$1' versioning}}}{{/if}}",
"currentValueTemplate": "{{#if gitRef}}{{{gitRef}}}{{else}}{{{archiveTag}}}{{/if}}",
},
],
"packageRules": [
{
"matchManagers": ["custom.regex"],
"matchFileNames": ["packaging/linux/flatpak/modules/**/*.json"],
"matchDatasources": ["github-release-attachments"],
// The datasource can return the old checksum if it cannot identify the pinned asset.
"matchJsonata": ["newValue != currentValue and newDigest and newDigest = currentDigest"],
"enabled": false,
},
],
}
Loading
Loading