Refactor publish package scripts