Versioning utilities
One of the most difficult tasks is to automatically and uniquely version command-line utilities, especially when using a CI/CD system. This section presents a technique that uses a GitHub value to version a command-line utility on your local machine.
You can apply the same technique to GitLab—just search for the available GitLab variables and values and choose one that fits your needs.
This technique is used by both the docker
and kubectl
utilities, among others:
$ docker version
Client: Docker Engine - Community
Cloud integration: 1.0.4
Version: 20.10.0
API version: 1.41
Go version: go1.13.15
Git commit: 7287ab3
Built: Tue Dec 8 18:55:43 2020
OS/Arch: darwin/amd64
...
The previous output shows that docker
uses the Git commit value for versioning—we are going to use a slightly different value that is longer than the one used by docker
.
The utility that...