add_action for unknown custom post types

The first one does not work because to use that format you need double quotes.

add_action( "publish_{$custom_post_type}" , 'run_new_post_code' );

That will let the wrapped variable name be processed properly.

To do something for all custom post types you probably just need to grab the list of custom post types and cycle through them adding an action for each one.

If you only want to do it for some of them, then you will have to give the users the ability to set an option somewhere to list which types to do each thing for.

<?php
$post_type_names = get_post_types( array(), 'names' );
foreach ( $post_type_names as $name ) {
   add_action( "publish_{$name}", 'run_new_post_code' );
}
?>

The above will cycle through each found post type.

See get_post_types for the list of arguments and how to use them.