Add forced-colors support and contrast guidance
CI / Test and package (push) Successful in 1m33s

This commit is contained in:
2026-11-21 19:32:59 +01:00
parent 50fe5ec2e9
commit 88eb56b0e0
+77
View File
@@ -27,6 +27,21 @@ jobs:
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Validate npm authentication
shell: bash
env:
NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"
run: |
set -euo pipefail
if [[ -z "${NODE_AUTH_TOKEN:-}" ]]; then
echo "::error::The NPM_TOKEN repository secret is missing or empty."
exit 1
fi
npm_identity="$(npm whoami)"
echo "Authenticated to npm as ${npm_identity}."
- name: Install locked dependencies
run: npm ci
@@ -43,7 +58,69 @@ jobs:
- name: Verify generated contracts are committed
run: git diff --exit-code -- utilities.css public-api.json package-lock.json
- name: Check npm publication status
id: registry
shell: bash
env:
NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"
run: |
set -euo pipefail
package_name="$(node -p "require('./package.json').name")"
package_version="$(node -p "require('./package.json').version")"
package_spec="${package_name}@${package_version}"
channel="${{ steps.release.outputs.channel }}"
local_metadata="$(npm pack --dry-run --json --ignore-scripts | node -e '
let input = "";
process.stdin.setEncoding("utf8");
process.stdin.on("data", chunk => input += chunk);
process.stdin.on("end", () => {
const [pack] = JSON.parse(input);
if (!pack?.integrity || !pack?.shasum) process.exit(1);
process.stdout.write(`${pack.integrity}|${pack.shasum}`);
});
')"
IFS='|' read -r local_integrity local_shasum <<< "${local_metadata}"
view_error="$(mktemp)"
if published_integrity="$(npm view "${package_spec}" dist.integrity 2>"${view_error}")"; then
published_shasum="$(npm view "${package_spec}" dist.shasum)"
if [[ -z "${published_integrity}" || -z "${published_shasum}" ]]; then
echo "::error::${package_spec} exists, but npm did not return complete integrity metadata."
exit 1
fi
if [[ "${published_integrity}" != "${local_integrity}" || "${published_shasum}" != "${local_shasum}" ]]; then
echo "::error::${package_spec} already exists on npm with different package contents."
echo "Local shasum: ${local_shasum}"
echo "Published shasum: ${published_shasum}"
exit 1
fi
published_channel_version="$(npm view "${package_name}" "dist-tags.${channel}")"
if [[ "${published_channel_version}" != "${package_version}" ]]; then
echo "::error::${package_spec} exists, but npm's ${channel} tag points to ${published_channel_version:-nothing}."
exit 1
fi
echo "publish=false" >> "${GITHUB_OUTPUT}"
echo "${package_spec} is already published with matching integrity; publication will be skipped."
elif grep -q "E404" "${view_error}"; then
echo "publish=true" >> "${GITHUB_OUTPUT}"
echo "${package_spec} is not published yet."
else
cat "${view_error}" >&2
echo "::error::Unable to determine whether ${package_spec} is already published."
exit 1
fi
- name: Publish package
if: steps.registry.outputs.publish == 'true'
run: npm publish --tag "${{ steps.release.outputs.channel }}" --access public
env:
NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"
- name: Report existing package
if: steps.registry.outputs.publish == 'false'
run: echo "The exact package version is already available on npm; nothing was published."