Generate local version identifier only during development

Fixes #10678.
2 jobs for master in 3 minutes and 2 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Test
passed #23428
code-quality

00:02:51

3.0%
 
  Build
passed #23429
linux

00:00:10