version_constraint, version_overrides
Some package attributes like asset and files may be different by it's version.
For example, the asset structure of golang-migrate was changed from v4.15.0.
In that case, the attributes version_constraint and version_overrides are useful.
e.g.
- type: github_release
repo_owner: golang-migrate
repo_name: migrate
asset: 'migrate.{{.OS}}-{{.Arch}}.tar.gz'
description: Database migrations. CLI and Golang library
version_constraint: 'semver("> 4.14.1")'
version_overrides:
- version_constraint: 'semver("<= 4.14.1")'
files:
- name: migrate
src: 'migrate.{{.OS}}-{{.Arch}}'
version_constraint is expr's expression.
The evaluation result must be a boolean.
Currently, the following values and functions are accessible in the expression.
Version: (type:string) The package versionSemVer: (type:string) The package version that version_prefix is trimmed fromVersion. For example, ifVersioniscli/v1.0.0andversion_prefixiscli/, thenSemVerisv1.0.0semver: (type:func(string) bool) Tests if the package version satisfies all the constraintssemverWithVersion: (type:func(constraint, version string) bool) Tests if the package version satisfies all the constraintstrimPrefix: (typefunc(s, prefix string) string) Go's strings.TrimPrefix
semver, semverWithVersion
See also Change the implementation of semver and semverWithVersion.
e.g.
semver("> 4.14.1")
semver("> 3.0.0, <= 4.0.0")
semverWithVersion is used when we need to format Version:
semverWithVersion(">= 0.11.1", trimPrefix(Version, "cli-"))
Syntax:
<operator> <version>[, <operator> <version> ...]
Supported operators:
>=<=!=><=
Support multiple constraints separated with comma ,.
Multiple constraints are evaluated as AND comparison.
Spaces are trimmed.
Constraints are evaluated using hashicorp/go-version.
version_overrides
The list of version override.
e.g.
version_overrides:
- version_constraint: 'semver("<= 4.14.1")'
files:
- name: migrate
src: 'migrate.{{.OS}}-{{.Arch}}'