OS.is_debug_build()
returns true
when running in the editor or a debug build, and returns false
in a release build.
Edit: Ignore the rest of this answer and look at Calinou's one.
You could also do something like:
# filename of your godot executable
var godot_exe = "Godot_v3.1.2-stable_win64.exe"
func check_if_exported():
var path = OS.get_executable_path()
if godot_exe in path:
return false
else:
return true
which returns true
in each exported build.
But your Godot's filename and the variable would need to be always equal.