For reasons that you shouldn’t have to worry about, this is a lot harder than it should be. Those version numbers can change without actually restarting the app instances.
You can set an environment variable at deploy time, however. Doing something like this might get you what you need:
flyctl deploy -e APP_REVISION=$(git rev-parse --short HEAD)
That will set the $APP_REVISION
env variable to the short git revision number.