fix(publish): Move `.crate` out of final artifact location
When target_dir == build_dir, ensure cargo publish doesn't put intermediate artifacts in the final artifact location of cargo package.
What does this PR try to resolve?
In #15910, users could identify that .crate files from cargo publish are not final artifacts by setting a custom build-dir. This extends that to all users, ie when build-dir = target-dir (the default currently), making it clear that these files are internal.
This also cleans things up by consolidating all of the uplifting logic and avoids dealing with overlapping target_dir and build_dir.
How to test and review this PR?
Notes
We could optimize this further by doing a rename and only doing a copy if that fails, effectively a rename_or_copy as opposed to our hardlink_or_copy we normally use for uplifting. The difference is that we don't do change tracking for .crate files but fully re-generate, so we don't benefit from keeping the .crate around in the original location.
r? @weihanglo
rustbot has assigned @weihanglo. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
:umbrella: The latest upstream changes (possibly 9191c77aa157eff5fb5a244908e0c8ddac74aaeb) made this pull request unmergeable. Please resolve the merge conflicts.
:umbrella: The latest upstream changes (possibly 8e43074b2365e1f908570d7f5c2ef76b19d1133c) made this pull request unmergeable. Please resolve the merge conflicts.