ci: replace upload step with a pre-exit hook
Created by: jhchabran
The previous approach proved to be unreliable in certain cases, especially when wait steps are getting involved.
This change now triggers a post-exit hook on every step that will upload if a hard failure is detected.
I have not documented the --overwrite-state
in SG's doc because that's not a flag meant to be used by our users.