@@ -215,18 +215,69 @@ jobs:
215215 chmod +x npm/platform/linux-x64/bin/diffmind
216216 npm/platform/linux-x64/bin/diffmind --version
217217
218+ # Every path below MUST start with "./".
219+ #
220+ # `npm publish <arg>` resolves its argument as a package spec, and a bare
221+ # two-segment path like `npm/cli` matches the GitHub shorthand
222+ # `github:npm/cli` — the npm CLI's own repository. npm then fetches, packs
223+ # and tries to publish *that*, producing a baffling
224+ # `403 Forbidden - PUT https://registry.npmjs.org/npm`. A leading "./"
225+ # forces the folder interpretation.
226+ #
218227 # Platform packages first: @diffmind/cli depends on them, and publishing
219228 # it first would briefly resolve to nothing.
220229 - name : Publish platform packages
221230 run : |
222- for dir in npm/platform/*/; do
231+ set -euo pipefail
232+ for dir in ./npm/platform/*/; do
223233 echo "publishing ${dir}"
224234 npm publish "${dir}" --provenance --access public
225235 done
226236 env :
227237 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
228238
229239 - name : Publish @diffmind/cli
230- run : npm publish npm/cli --provenance --access public
240+ run : npm publish ./npm/cli --provenance --access public
241+ env :
242+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
243+
244+ # A publish that fails partway leaves @diffmind/cli depending on platform
245+ # packages that do not exist — `npm i -g @diffmind/cli` then installs a
246+ # launcher with no binary to launch. That went unnoticed for several
247+ # releases, so assert the whole set is really on the registry.
248+ - name : Verify all six packages published
249+ run : |
250+ set -uo pipefail
251+ VERSION="${GITHUB_REF_NAME#v}"
252+ PACKAGES="@diffmind/cli"
253+ for dir in ./npm/platform/*/; do
254+ PACKAGES="${PACKAGES} @diffmind/cli-$(basename "${dir}")"
255+ done
256+
257+ MISSING=""
258+ for pkg in ${PACKAGES}; do
259+ # The registry is read-through-cached, so a fresh publish can take a
260+ # moment to become visible.
261+ FOUND=""
262+ for attempt in 1 2 3 4 5; do
263+ if npm view "${pkg}@${VERSION}" version >/dev/null 2>&1; then
264+ FOUND="yes"
265+ break
266+ fi
267+ sleep 10
268+ done
269+ if [ -n "${FOUND}" ]; then
270+ echo " ok ${pkg}@${VERSION}"
271+ else
272+ echo " MISSING ${pkg}@${VERSION}"
273+ MISSING="${MISSING} ${pkg}"
274+ fi
275+ done
276+
277+ if [ -n "${MISSING}" ]; then
278+ echo "::error::not published:${MISSING}"
279+ exit 1
280+ fi
281+ echo "All packages published at ${VERSION}."
231282 env :
232283 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments