Version and tag generation

For automatic version generation from Git project metadata, rpkg offers git_version family of macros that rely on Git tags (or at least the most recent one) having names of a certain structure, that structure being:


When git_version macro is being evaluated, it looks up name of the most recent tag that fits the above pattern and from that tag name, it determines the current package version. Apart from the latest tag name, also commit count from that latest tag and Git working tree “dirtiness” are taken into account when generating the version string. See full details here.

If you are creating a new tag with rpkg tag command, a similar procedure takes place but this time, rpkg hints git_version macro that it should “bump” the version instead of generating it in the usual manner and the macro will react by incrementing “follow” number in the latest tag’s <version> string and using that resulting version string as its output value (see again git_version for details and exact definition of the “follow” number).

When git_version and all the other rpkg macros in the input spec file template are evaluated and the final rpm spec file is rendered, rpkg reads out resulting values of Name:, Version: and Release: rpm fields from that spec file and uses those values to create a new tag named <name>-<version>-<release>, where <name>, <version>, and <release> are the individual discovered values for the fields.

Note that when spec file is evaluated to get the tag name, value of %{?dist} rpm macro is unset by rpkg so that it never occurs in the resulting tag name. This macro is typically used in Release: rpm spec field.