Golang go.mod
kind: golang/gomod
Description
The golang/gomod
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 |
---|---|---|---|
ignore | array | ignore allows to specify “rule” to ignore autodiscovery a specific go.mod rule | |
goversion | string | GoVersions specifies a list of version pattern. | |
modules | object | Modules specifies a list of module pattern. | |
path | string | Path specifies a go.mod path pattern, the pattern requires to match all of name, not just a substring. | |
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. | |
modules | object | Modules specifies a list of module pattern. | |
path | string | Path specifies a go.mod path pattern, the pattern requires to match all of name, not just a substring. | |
rootdir | string | rootDir defines the root directory used to recursively search for golang go.mod | |
versionfilter | object |
| |
kind | string | specifies the version kind such as semver, regex, or latest | |
pattern | string | specifies the version pattern according the version kind | |
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 pullrequest 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/gomod:
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 pullrequest 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/gomod:
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: