How to set app version for ESP32

I believe that the ESP_IDF behavior can be replicated with pio Advanced Scripting. Will describe my journey in this post.