Carles: fix build.sh and add a publish script

ditto.