Is it possible to export a project using only GDScript?

Godot Version

4.4 beta 3

Question

I want to create an EditorScript or plugin tool for exporting and uploading my projects. I know that you can execute shell commands but exporting from the command line using commands like the one below has been quite unstable for me. Is there’s a way to run the functionality of the Export All... button using only GDScript?

godot --export-release "Windows Desktop" some_name.exe