Move some functionality from publish() to PluginStep.process_lifecycle()

The functionality that was in publish() is generally useful and should live in
PluginStep.