When publishing using org-babel-tangle-publish to the same directory that contains the org files, copy-file will signal an error, since the source and destination files refer to the same file. So use rename-file instead. When publishing to a different directory, this change also cleans up the old files, which matches the behavior of the other publishing functions like org-html-publish-to-html.