Build Metadata (+) Is Ignored in Precedence
SemVer build metadata like 1.0.0+20230101 or 1.0.0+build.42 is ignored when comparing versions. Learn why and when to use it.
Detailed Explanation
Build Metadata in SemVer
Build metadata is appended to a version using a + sign followed by dot-separated identifiers.
Format
MAJOR.MINOR.PATCH[-prerelease][+build]
Examples:
1.0.0+20230101— build date1.0.0+build.42— build number1.0.0-beta.1+exp.sha.5114f85— pre-release with Git SHA
The Golden Rule
Build metadata MUST be ignored when determining version precedence.
This means:
1.0.0+build.1=1.0.0+build.2(for comparison purposes)1.0.0+build.1=1.0.0(for comparison purposes)
Why Does Build Metadata Exist?
Build metadata exists for informational purposes only:
| Use Case | Example |
|---|---|
| Git commit SHA | 1.0.0+sha.a1b2c3d |
| Build date/time | 1.0.0+20230615.143022 |
| CI build number | 1.0.0+build.1234 |
| Platform | 1.0.0+linux.amd64 |
Build Metadata vs Pre-release
| Aspect | Pre-release (-) | Build Metadata (+) |
|---|---|---|
| Affects precedence | Yes | No |
| Example | 1.0.0-alpha |
1.0.0+build.1 |
| Published to npm | Yes | Rarely |
| Compared during sort | Yes | No |
Combined Usage
You can have both pre-release and build metadata:
2.0.0-rc.1+build.123
The pre-release part (rc.1) affects precedence, but the build part (build.123) does not.
In Practice
Most package managers (npm, Cargo, pub) strip or ignore build metadata during resolution. It is mainly useful for internal tracking and debugging deployment artifacts.
Use Case
Tagging builds in CI/CD pipelines with additional metadata (Git SHA, build number, date) while maintaining correct version ordering for package resolution.