mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-07 16:35:48 +01:00
fix(release): address provenance publish review
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
2ad29da807
commit
11094230c4
2 files changed
+27
-4
No files matched your search
@@ -278,7 +278,7 @@ publish_package_to_npm() {
|
||||
|
||||
publish_log="$(mktemp "${TMPDIR:-/tmp}/paperclip-npm-publish.XXXXXX")"
|
||||
|
||||
if pnpm publish --no-git-checks --tag "$dist_tag" --access public 2>&1 | tee "$publish_log"; then
|
||||
if (set -o pipefail; pnpm publish --no-git-checks --tag "$dist_tag" --access public 2>&1 | tee "$publish_log"); then
|
||||
rm -f "$publish_log"
|
||||
return 0
|
||||
fi
|
||||
@@ -296,6 +296,12 @@ publish_package_to_npm() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$dist_tag" != "canary" ]; then
|
||||
release_warn "Not retrying ${package_name}@${package_version} without provenance for dist-tag ${dist_tag}."
|
||||
rm -f "$publish_log"
|
||||
return 1
|
||||
fi
|
||||
|
||||
release_warn "Retrying ${package_name}@${package_version} once with npm provenance disabled."
|
||||
if pnpm publish --no-git-checks --tag "$dist_tag" --access public --provenance=false; then
|
||||
rm -f "$publish_log"
|
||||
|
||||
@@ -11,7 +11,7 @@ function writeExecutable(path, body) {
|
||||
writeFileSync(path, body, { mode: 0o755 });
|
||||
}
|
||||
|
||||
function runPublishHelper({ pnpmMode, npmVersionExists = false }) {
|
||||
function runPublishHelper({ pnpmMode, npmVersionExists = false, distTag = "canary", callerPipefail = true }) {
|
||||
const fixtureDir = mkdtempSync(join(tmpdir(), "paperclip-release-lib-"));
|
||||
const binDir = join(fixtureDir, "bin");
|
||||
const stateDir = join(fixtureDir, "state");
|
||||
@@ -74,10 +74,11 @@ exit 1
|
||||
`,
|
||||
);
|
||||
|
||||
const shellOptions = callerPipefail ? "set -euo pipefail" : "set -eu";
|
||||
const script = `
|
||||
set -euo pipefail
|
||||
${shellOptions}
|
||||
source "${repoRoot}/scripts/release-lib.sh"
|
||||
publish_package_to_npm canary @paperclipai/example 1.2.3
|
||||
publish_package_to_npm ${distTag} @paperclipai/example 1.2.3
|
||||
`;
|
||||
|
||||
let status = 0;
|
||||
@@ -144,3 +145,19 @@ test("publish_package_to_npm does not retry unrelated publish failures", () => {
|
||||
assert.doesNotMatch(result.calls, /npm view/);
|
||||
assert.doesNotMatch(result.calls, /--provenance=false/);
|
||||
});
|
||||
|
||||
test("publish_package_to_npm does not mask failures when caller has no pipefail", () => {
|
||||
const result = runPublishHelper({ pnpmMode: "non-tlog-failure", callerPipefail: false });
|
||||
|
||||
assert.notEqual(result.status, 0);
|
||||
assert.doesNotMatch(result.calls, /npm view/);
|
||||
assert.doesNotMatch(result.calls, /--provenance=false/);
|
||||
});
|
||||
|
||||
test("publish_package_to_npm does not retry stable publishes without provenance", () => {
|
||||
const result = runPublishHelper({ pnpmMode: "tlog-then-success", distTag: "latest" });
|
||||
|
||||
assert.notEqual(result.status, 0);
|
||||
assert.match(result.calls, /^npm view @paperclipai\/example@1\.2\.3 version$/m);
|
||||
assert.doesNotMatch(result.calls, /--provenance=false/);
|
||||
});
|
||||
Reference in new issue
Block a user