D4: pass --ignore-scripts to per-platform npm publish/pack
The main npm package already publishes and packs with --ignore-scripts, but the per-platform subpackage loop did not: `npm publish --access public`, its retry, and the per-platform `npm pack` all ran lifecycle scripts from the package directory with the npm token in scope. Add --ignore-scripts to all three, matching the main package, so no prepublish/prepare hook can execute during a release.
This commit is contained in:
@@ -232,13 +232,17 @@ jobs:
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
echo "::group::publish $pkgname@$version"
|
echo "::group::publish $pkgname@$version"
|
||||||
(cd "$dir" && npm publish --access public)
|
# --ignore-scripts: a per-platform package must never run lifecycle
|
||||||
|
# scripts during publish (npm runs prepublishOnly/prepare/etc. from
|
||||||
|
# the package being published — a malicious or stray script would
|
||||||
|
# execute with the npm token in the environment).
|
||||||
|
(cd "$dir" && npm publish --access public --ignore-scripts)
|
||||||
local rc=$?
|
local rc=$?
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
if [ "$rc" -ne 0 ]; then
|
if [ "$rc" -ne 0 ]; then
|
||||||
echo "::warning::first attempt of $pkgname failed (rc=$rc); retrying after 30s"
|
echo "::warning::first attempt of $pkgname failed (rc=$rc); retrying after 30s"
|
||||||
sleep 30
|
sleep 30
|
||||||
(cd "$dir" && npm publish --access public)
|
(cd "$dir" && npm publish --access public --ignore-scripts)
|
||||||
rc=$?
|
rc=$?
|
||||||
fi
|
fi
|
||||||
if [ "$rc" -ne 0 ]; then
|
if [ "$rc" -ne 0 ]; then
|
||||||
@@ -284,9 +288,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Main package
|
# Main package
|
||||||
npm pack --ignore-scripts
|
npm pack --ignore-scripts
|
||||||
# Each per-platform package (the binaries were already moved in by napi artifacts)
|
# Each per-platform package (the binaries were already moved in by
|
||||||
|
# napi artifacts). --ignore-scripts for the same reason as publish:
|
||||||
|
# packing must not execute lifecycle scripts from the packed dir.
|
||||||
for d in npm/*/; do
|
for d in npm/*/; do
|
||||||
(cd "$d" && npm pack)
|
(cd "$d" && npm pack --ignore-scripts)
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Upload Node tarballs
|
- name: Upload Node tarballs
|
||||||
|
|||||||
Reference in New Issue
Block a user