Configure Renovate to suggest AGP version bumps #1742
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Automate the discovery of new AGP versions. While there's an existing workflow for bumping the AGP versions in this project, it must be manually triggered specifying the new version. Renovate can fill this gap by suggesting updates whenever new versions come out.
Renovate
Renovate is a tool like Dependabot but much more flexible. It has built-in "managers" such as
maven
,gradle
, andpip_requirements
that look for certain patterns in certain files, then query "datasources" for newer versions. No built-in manager supports the customversions.json
file, but Renovate allows for creating a custom regex-based manager.Renovate custom manager
A Renovate config file is added with a custom "regex" manager. This can instruct Renovate to parse any version on any file. The goal is to detect and update AGP versions annotated with a comment:
The "manager" config declares
An example PR is available in a fork: gabrielfeo#10.
The last four elements are commonly set on each comment and captured with regex (example), but I opted to centralize them in the Renovate config to minimize duplication, simplify the comments and the regex that parses them.
Changes
versions.json
with a "renovate: AGP version" commentversions.json5
to keep syntax highlighting support when adding commentsJsonSlurper
s toLAX
mode, which is lenient about comments (Groovy has no support for JSON5)versions.json5
andgradle.properties
too (for the build-time check described below)WorkaroundTest
no longer specifies patch numbers. Updating these is something that the existing workflow takes care of, but can't be as easily done with Renovate. Thanks to @erichaagdev for this suggestion.gradle.properties
and fail the build if it's missing fromversions.json5
. The goal is to have Renovate create a "nudge" PR if a new major or minor comes out (versions.json5
has major/minor bumps disabled in order to keep older minor versions in the list of "supportedVersions"). The property isn't used for anything else. Thanks to @erichaagdev for this suggestion.Pending work