Golang
kind: golang
Description
The golang autodiscovery plugin allows to automatically search and update go.mod files.
It handles golang version update and golang module version update.
Manifests
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| age | object | Age defines the minimum or maximum age of a release to be considered valid.
It accepts a duration string (e.g., 24h, 7d, 1w). |
|
| maximum | string | Maximum defines the maximum age of a release to be considered valid. It accepts a duration string (e.g., “24h”, “7d”, “3w”, “1y”). Accepted time units are “h” for hours, “d” for days, “w” for weeks, “mo” for months, and “y” for years. If no unit is provided, hours are assumed. | |
| minimum | string | Minimum defines the minimum age of a release to be considered valid. It accepts a duration string (e.g., “24h”, “7d”, “3w”, “1y”). Accepted time units are “h” for hours, “d” for days, “w” for weeks, “mo” for months, and “y” for years. If no unit is provided, hours are assumed. | |
| ignore | array | ignore allows to specify rule to ignore autodiscovery a specific go.mod rule |
|
| goversion | string | GoVersions specifies a list of version pattern. The version constraint must be a valid semantic version constraint. If GoVersion is empty then any version is matching. Example:
|
|
| modules | object | Modules specifies a list of module pattern. The module accepts regular expression for module name and semantic versioning constraint for module version. If module version is empty then any version is matching. Example:
|
|
| path | string | Path specifies a go.mod path pattern The pattern syntax is: pattern: { term } term: ‘’ matches any sequence of non-Separator characters ‘?’ matches any single non-Separator character ‘[’ [ ‘^’ ] { character-range } ‘]’ character class (must be non-empty) c matches character c (c != ‘’, ‘?’, ‘\’, ‘[’) ‘\’ c matches character c example:
|
|
| replace | boolean | Replace indicates if the module is a replace directive. If Replace is nil then any module is matching. If Replace is true then only module with a replace directive is matching. If Replace is false then only module without a replace directive is matching. | |
| only | array | only allows to specify rule to only autodiscover manifest for a specific golang rule |
|
| goversion | string | GoVersions specifies a list of version pattern. The version constraint must be a valid semantic version constraint. If GoVersion is empty then any version is matching. Example:
|
|
| modules | object | Modules specifies a list of module pattern. The module accepts regular expression for module name and semantic versioning constraint for module version. If module version is empty then any version is matching. Example:
|
|
| path | string | Path specifies a go.mod path pattern The pattern syntax is: pattern: { term } term: ‘’ matches any sequence of non-Separator characters ‘?’ matches any single non-Separator character ‘[’ [ ‘^’ ] { character-range } ‘]’ character class (must be non-empty) c matches character c (c != ‘’, ‘?’, ‘\’, ‘[’) ‘\’ c matches character c example:
|
|
| replace | boolean | Replace indicates if the module is a replace directive. If Replace is nil then any module is matching. If Replace is true then only module with a replace directive is matching. If Replace is false then only module without a replace directive is matching. | |
| onlygomodule | boolean | OnlyGoModule allows to specify if the autodiscovery should only handle Go module specified in go.mod | |
| onlygoversion | boolean | OnlyGoVersion allows to specify if the autodiscovery should only handle Go version specified in go.mod | |
| rootdir | string | rootDir defines the root directory used to recursively search for golang go.mod | |
| versionfilter | object |
kind - semver
versionfilter of kind kind - regex
versionfilter of kind example:
and its type like regex, semver, or just latest. More examples can be found at https://www.updatecli.io/docs/core/versionfilter/ |
|
| kind | string | specifies the version kind such as semver, regex, or latest | |
| pattern | string | specifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format | |
| regex | string | specifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used. | |
| replaceall | object | replaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction. | |
| pattern | string | Pattern specifies the regex pattern to match for replacement | |
| replacement | string | Replacement specifies the replacement string (supports $1, $2, etc. for captured groups) | |
| strict | boolean | strict enforce strict versioning rule. Only used for semantic versioning at this time |
Example
Golang update only
In the following example, we want to automate minor version update of Golang, such as from "1.19" to "1.20" If Updatecli detects a change, then it opens a new pull request with the propose version update.
# updatecli.d/default.yaml
name: "Bump Golang Version"
scms:
default:
kind: github
spec:
owner: olblak
repository: updatecli
token: {{ requiredEnv "GITHUB_TOKEN" }}
username: {{ requiredEnv "GITHUB_ACTOR" }}
branch: main
actions:
default:
kind: github/pullrequest
scmid: default
spec:
labels:
- "dependencies"
autodiscovery:
scmid: default
actionid: default
crawlers:
golang:
versionfilter:
kind: semver
pattern: minor
only:
- goversion: "*"
Semantic version patch update only
In this example, Updatecli is looking for all version that can have a patch version update. If at least one version needs to be updated, then it opens a single pull request with all the version bump.
# updatecli.d/default.yaml
name: "Bump Patch version for Golang module"
scms:
default:
kind: github
spec:
owner: olblak
repository: updatecli
token: {{ requiredEnv "GITHUB_TOKEN" }}
username: {{ requiredEnv "GITHUB_ACTOR" }}
branch: main
actions:
default:
# The action title is used to define the pullrequest title
# Since we use the groupby set to all we need to be sure that the pullrequest title
# is the same for all the pipeline generated by autodiscovery.
title: Bump Patch version for Golang module
kind: github/pullrequest
scmid: default
spec:
labels:
- "dependencies"
autodiscovery:
scmid: default
actionid: default
groupby: all
crawlers:
golang:
versionfilter:
kind: semver
pattern: patch
ignore:
- modules:
# Ignoring the following modules as they do not publish release
github.com/ProtonMail/go-crypto:
# Ignoring the following modules as they do not publish release
github.com/shurcooL/githubv4:
# Ignore module using version matching constraint 1.x
helm.sh/helm/v3: "1.x"
# The remote version uses the version v0.0.0-20190318233801-ac98e3ecb4b0 which do not exists anymore
# the patch version will try to fetch the version matching 0.0.x and finds nothing
github.com/iancoleman/orderedmap:
# Same for https://pkg.go.dev/golang.org/x/time?tab=versions
golang.org/x/time: