diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f756ecd..c09d02b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,8 +64,21 @@ jobs: # No token: OIDC exchanges the workflow's id-token, which is also what attaches provenance. # `tee` because the release body is built from what this actually did rather than from a guess # about what it would do. + # + # Two details in this one line, both of which produce a *silently wrong* release when missed: + # + # `shell: bash` — the default shell here is `bash -e`, without `pipefail`, so a pipeline + # reports the exit status of its LAST command. That is `tee`, which always + # succeeds. A failed publish would have been reported as a green step, and + # a GitHub release created for it. Naming the shell gets `-eo pipefail`. + # + # `2>&1` — deno's logger is env_logger, whose default target is stderr, so every + # "Successfully published" line goes there. Measured: a publish writes 0 + # lines to stdout and all of them to stderr. Without this the log is empty + # and the release notes say nothing shipped while three packages did. - name: Publish - run: deno publish | tee /tmp/publish.log + shell: bash + run: deno publish 2>&1 | tee /tmp/publish.log - name: Release notes run: node scripts/release.mjs --notes /tmp/publish.log "$GITHUB_REF_NAME" > /tmp/notes.md diff --git a/scripts/release.mjs b/scripts/release.mjs index 8f9b7b2..1130c8c 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -96,6 +96,21 @@ function notes(logPath, tag) { const shipped = [...plain.matchAll(/Successfully published (@[^@\s]+\/[^@\s]+)@(\S+)/g)] .map(([, name, version]) => ({ name, version })); + // A log carrying neither marker is not "nothing was published" — it is a log this script cannot + // read, and the two are indistinguishable from the text alone. Saying nothing shipped when three + // packages did is the worse failure, and it is silent, so refuse instead of guessing. + // + // This is not hypothetical: the first version of this workflow piped only stdout, while deno logs + // to stderr, so every successful release would have produced an empty log and a release body + // announcing that nothing happened. + if (shipped.length === 0 && !/already published/.test(plain)) { + throw new Error( + `${logPath} contains neither "Successfully published" nor "already published". ` + + 'Either the publish did not run, or its output is not being captured — check that the step ' + + 'redirects stderr (deno logs there) and that the pipeline uses pipefail.', + ); + } + if (shipped.length === 0) { return `No package versions were published by \`${tag}\` — every version in the workspace was already on JSR.`; }