add_action hook for publish_post not working

When a post is published/saved, it does not do it in a single script execution. It redirects to a different script, does the save, then redirects back to where you started. If you want to confirm that your hook is working, use update_option(), and delete the option immediately after displaying it so it’s not latent (alternatively: you can make the option count up or something, there’s quite a bit you could do, be creative).

Also, the hook you’re looking for is save_post, it fires on both wp_insert_post() and wp_update_post() (which are actually both running through wp_insert_post() anyways, just FWIW).