fix(publish): Move .crate
out of final artifact location
#15915
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
target_dir == build_dir
, ensurecargo publish
doesn't put intermediate artifacts in the final artifact location ofcargo package
.What does this PR try to resolve?
In #15910, users could identify that
.crate
files fromcargo publish
are not final artifacts by setting a custombuild-dir
. This extends that to all users, ie whenbuild-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
andbuild_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 arename_or_copy
as opposed to ourhardlink_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.