chore(build): refactor build scripts in prepare/publish cycle