Skip to content

Commit

Permalink
fix(publish): workspace included license file had incorrect path (#24747
Browse files Browse the repository at this point in the history
)

Also fixes the issue where we say a package was successfully published
before it wasn't.

Bug in #24714
  • Loading branch information
dsherret committed Jul 26, 2024
1 parent ecaf922 commit 6429eff
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
18 changes: 9 additions & 9 deletions cli/tools/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl PublishPreparer {
publish_paths.push(CollectedPublishPath {
specifier: ModuleSpecifier::from_file_path(&license_path)
.unwrap(),
relative_path: "LICENSE".to_string(),
relative_path: "/LICENSE".to_string(),
maybe_content: Some(std::fs::read(&license_path).with_context(
|| format!("failed reading '{}'.", license_path.display()),
)?),
Expand Down Expand Up @@ -1014,14 +1014,6 @@ async fn publish_package(
);
}

log::info!(
"{} @{}/{}@{}",
colors::green("Successfully published"),
package.scope,
package.package,
package.version
);

let enable_provenance = std::env::var("DISABLE_JSR_PROVENANCE").is_err()
&& (auth::is_gha() && auth::gha_oidc_token().is_some() && provenance);

Expand Down Expand Up @@ -1071,6 +1063,14 @@ async fn publish_package(
.await?;
}

log::info!(
"{} @{}/{}@{}",
colors::green("Successfully published"),
package.scope,
package.package,
package.version
);

log::info!(
"{}",
colors::gray(format!(
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/registry/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pub enum PackagePathValidationError {
pub struct CollectedPublishPath {
pub specifier: ModuleSpecifier,
pub path: PathBuf,
/// Relative path to use in the tarball.
/// Relative path to use in the tarball. This should be prefixed with a `/`.
pub relative_path: String,
/// Specify the contents for any injected paths.
pub maybe_content: Option<Vec<u8>>,
Expand Down
1 change: 1 addition & 0 deletions cli/tools/registry/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub fn create_gzipped_tarball(
hash: format!("sha256-{:x}", sha2::Sha256::digest(&content)),
size: content.len(),
});
assert!(path_str.starts_with('/'));
tar
.add_file(format!(".{}", path_str), &content)
.with_context(|| {
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/publish/successful_provenance.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Check file:///[WILDCARD]/publish/successful/mod.ts
Checking for slow types in the public API...
Check file:///[WILDCARD]/publish/successful/mod.ts
Publishing @foo/[email protected] ...
Successfully published @foo/[email protected]
Provenance transparency log available at https://search.sigstore.dev/?logIndex=42069
Successfully published @foo/[email protected]
Visit http://127.0.0.1:4250/@foo/[email protected] for details

0 comments on commit 6429eff

Please sign in to comment.