Skip to content
Prev Previous commit
Next Next commit
ci(repo): validate package names in dispatched release
  • Loading branch information
nikosdouvlis committed Apr 14, 2026
commit 46e097c3ceeb9ffbf541bf4f9625ffc7c4ea7307
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,18 @@
exit 1
fi

- name: Reject "latest" dist_tag
- name: Validate packages
env:
PACKAGES: ${{ inputs.packages }}
run: |
echo "$PACKAGES" | jq -e 'all(.[]; .dist_tag != "latest")' > /dev/null || {
echo "::error::'latest' dist_tag is not allowed on this path"; exit 1;
}
invalid=$(echo "$PACKAGES" | jq -r '.[] | select(.name | test("^@clerk/[a-z0-9][a-z0-9-]*$") | not) | .name')
if [ -n "$invalid" ]; then
echo "::error::Invalid package name(s). Expected @clerk/<kebab-case>. Got: $invalid"
exit 1
fi

Comment thread
nikosdouvlis marked this conversation as resolved.
- name: Checkout source_ref
uses: actions/checkout@v4
Expand All @@ -592,76 +597,76 @@
echo "manager=npm" >> "$GITHUB_OUTPUT"
fi

- name: Install dependencies
run: |
if [ "${{ steps.pm.outputs.manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
else
npm ci
fi

- name: Build

Check failure

Code scanning / CodeQL

Untrusted Checkout TOCTOU Critical

Insufficient protection against execution of untrusted code on a privileged workflow (
issue_comment
).
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment on lines +606 to +626
run: |
if [ "${{ steps.pm.outputs.manager }}" = "pnpm" ]; then
pnpm build
else
npm run build
fi

- name: Upgrade npm for trusted publishing

Check failure

Code scanning / CodeQL

Untrusted Checkout TOCTOU Critical

Insufficient protection against execution of untrusted code on a privileged workflow (
issue_comment
).
Comment on lines +626 to +634
run: npx npm@11 install -g npm@11

- name: Publish or dry-run
env:
NPM_CONFIG_PROVENANCE: true
PACKAGES: ${{ inputs.packages }}
DRY_RUN: ${{ inputs.dry_run }}
PACK: ${{ steps.pm.outputs.manager }}
run: |
echo "$PACKAGES" | jq -r '.[] | [.name, .version, .dist_tag] | @tsv' | while IFS=$'\t' read -r name version tag; do
short="${name#@clerk/}"
dir="packages/$short"

if [ ! -d "$dir" ]; then
echo "::error::Package directory not found: $dir"
exit 1
fi

pkg_version=$(jq -r .version "$dir/package.json")
if [ "$pkg_version" != "$version" ]; then
echo "::error::$dir/package.json has version $pkg_version, expected $version"
exit 1
fi

echo "::group::Pack $name@$version"
if [ "$PACK" = "pnpm" ]; then
out=$(cd "$dir" && pnpm pack --json 2>/dev/null || true)
if [ -n "$out" ] && echo "$out" | jq -e . >/dev/null 2>&1; then
tarball=$(echo "$out" | jq -r '.filename')
else
# pnpm pack without --json prints the tarball path on stdout
tarball=$(cd "$dir" && pnpm pack 2>&1 | tail -n1 | xargs -I{} basename "{}")
fi
else
tarball=$(cd "$dir" && npm pack --json | jq -r '.[0].filename')
fi
if [ -z "$tarball" ] || [ ! -f "$dir/$tarball" ]; then
echo "::error::Failed to resolve tarball filename in $dir"
exit 1
fi
echo "packed: $dir/$tarball"
echo "::endgroup::"
Comment thread
nikosdouvlis marked this conversation as resolved.

if [ "$DRY_RUN" = "true" ]; then
echo "::notice::DRY RUN: would publish $name@$version --tag $tag"
else
echo "::group::Publish $name@$version --tag $tag"
(cd "$dir" && npm publish "$tarball" --tag "$tag" --provenance)
echo "::endgroup::"
fi
done
Comment thread
nikosdouvlis marked this conversation as resolved.

- name: Summary

Check failure

Code scanning / CodeQL

Untrusted Checkout TOCTOU Critical

Insufficient protection against execution of untrusted code on a privileged workflow (
issue_comment
).
Comment on lines +637 to +694
if: always()
env:
SOURCE_REF: ${{ inputs.source_ref }}
Expand Down
Loading