English Japanese
Use the upstream verbatim in the `+Version:+` tag. Don't trim leading zeroes.
Use a `+Release:+` tag starting with 1 (never 0). Append the xref:DistTag.adoc[Dist Tag]. Increment the release (by 1) for each update you make. Reset to 1 whenever you change `+Version:+`.
Complex versioning
There are several ways in which the simple scheme might not work in a particular situation:
Upstream has never chosen a version; only snapshots are available for packaging.
Upstream simply doesn't use a version scheme which orders properly under RPM's version comparison operation.
You wish to package a prerelease version (snapshot or otherwise).
You wish to package a postrelease snapshot.
Upstream was thought to be following one scheme but then changed in a way that does not sort properly.
You need to apply a small fix to a release branch of Fedora without updating the newer branches.
More than one of the above may apply (lucky you). Follow all of the relevant recommendations below together.
Handling non-sorting versions with tilde, dot, and caret
The tilde symbol ('`+~+`') is used before a version component which must sort *earlier* than any non-tilde component. It is used for any pre-release versions which wouldn't otherwise sort appropriately.
For example, with upstream releases `+0.4.0+`, `+0.4.1+`, `+0.5.0-rc1+`, `+0.5.0-rc2+`, `+0.5.0+`, the two "release candidates" should use `+0.5.0~rc1+` and `+0.5.0~rc2+` in the `+Version:+` field.
Bugfix or "patchlevel" releases that some upstream make should be handled using simple versioning. The separator used by upstream may need to be replaced by a dot or dropped.
For example, if the same upstream released `+0.5.0-post1+` as a bugfix version, this "post-release" should use `+0.5.0.post1+` in the `+Version:+` field. Note that `+0.5.0.post1+` sorts lower than both `+0.5.1+` and `+0.5.0.1+`.
The caret symbol ('`+^+`') is used before a version component which must sort *later* than any non-caret component. It is used for post-release snapshots, see next section.
The caret operator is not supported in RHEL7 which has rpm 4.11. If you need to support RHEL7/EPEL7 from the same specfile, use <<Traditional versioning with part of the upstream version information in the release field>> instead.
Snapshots
Snapshots (a version taken from the upstream source control system not associated with a release), **must** contain a snapshot information field after a caret (`+^+`). The first part of the field ensures proper sorting. That field may either the date in eight-digit "YYYYMMDD" format, which specifies the last modification of the source code, or a number. The packager **may** include up to 17 characters of additional information after the date, specifying the version control system and commit identifier. The snapshot information field is appended to version field described above, possibly including the pre-release and patchlevel information.