Output githash or similar software version

Hi does there exist a preferred way or any easy way to:

Output information from all flows that can be used for traceability of existing software version.
I would like to send this to database.