Indeed, the registry and Terraform itself both aim to use the semver precedence algorithm to decide which is the “newest” matching version, which specifies that only prerelease portions consisting entirely of digits get compared numerically.
- Identifiers consisting of only digits are compared numerically.
- Identifiers with letters or hyphens are compared lexically in ASCII sort order.
So if you intend to release more than nine prereleases of the same main version then you’d need to either use the period-separated version you noted, like
v1.0.0-pre.5, or to preemptively zero-pad your numeric part like
Semver doesn’t include any rules for deciding whether a particular version matches a version constraint, so it’s also worth noting that Terraform has a special treatment of prerelease versions, where it’ll select them only for exact versions and never for bounded version sets. Specifically,
>= 1.0.0 can’t match
v1.1.0-beta.1 even though it the beta has a higher precedence, because Terraform excludes the prerelease version from consideration unless the calling module specifies exactly
version = "1.0.0-beta.1".