mirror of
https://github.com/NomaDamas/k-skill.git
synced 2026-06-24 02:04:11 +00:00
fix(ci): add npm auth preflight to release workflow
fix(ci): add npm auth preflight to catch publish permission failures early
This commit is contained in:
commit
ed30f22f86
1 changed files with 35 additions and 0 deletions
35
.github/workflows/release-npm.yml
vendored
35
.github/workflows/release-npm.yml
vendored
|
|
@ -37,6 +37,41 @@ jobs:
|
|||
- run: npm ci
|
||||
- run: npm run ci
|
||||
|
||||
- name: Preflight – verify npm auth
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "::group::npm whoami"
|
||||
NPM_USER=$(npm whoami 2>&1) || {
|
||||
echo "::error::npm whoami failed – NPM_TOKEN is invalid or expired. Rotate the token and update the repository secret."
|
||||
exit 1
|
||||
}
|
||||
echo "Authenticated as: ${NPM_USER}"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Preflight – list unpublished packages (diagnostic)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "Packages that will be published:"
|
||||
FOUND=0
|
||||
for pkg_json in packages/*/package.json; do
|
||||
PRIVATE=$(node -e "console.log(require('./${pkg_json}').private || false)")
|
||||
[ "$PRIVATE" = "true" ] && continue
|
||||
|
||||
PKG=$(node -e "console.log(require('./${pkg_json}').name)")
|
||||
LOCAL_VER=$(node -e "console.log(require('./${pkg_json}').version)")
|
||||
REMOTE_VER=$(npm view "${PKG}" version 2>/dev/null || echo "")
|
||||
|
||||
if [ "${LOCAL_VER}" != "${REMOTE_VER}" ]; then
|
||||
echo " → ${PKG}@${LOCAL_VER} (npm: ${REMOTE_VER:-not yet published})"
|
||||
FOUND=1
|
||||
fi
|
||||
done
|
||||
if [ "$FOUND" -eq 0 ]; then
|
||||
echo " (none – all versions are already on npm)"
|
||||
fi
|
||||
|
||||
- name: Create npm release PR or publish changed packages
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue