Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/release-dispatch-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
NPM_CONFIG_PROVENANCE: true

- name: Trigger workflows on related repos
id: trigger
if: steps.changesets.outputs.published == 'true'
uses: actions/github-script@v7
with:
Expand Down Expand Up @@ -114,6 +115,87 @@ jobs:
core.warning("Changeset in pre-mode should not prepare a ClerkJS production release")
}

# Recovery: if the changesets action published to npm but then failed
# (e.g. git push --follow-tags error), the `published` output is never
# set and downstream repos are not notified. This step detects that
# scenario by checking npm for the local package version and dispatches
# if the packages are already live.
- name: Recover downstream notifications
if: always() && steps.changesets.conclusion == 'failure'
uses: actions/github-script@v7
with:
result-encoding: string
retries: 3
retry-exempt-status-codes: 400,401
github-token: ${{ secrets.CLERK_COOKIE_PAT }}
script: |
const { execSync } = require('child_process');

const clerkjsVersion = require('./packages/clerk-js/package.json').version;
const clerkUiVersion = require('./packages/ui/package.json').version;

// Only recover stable releases
if (clerkjsVersion.includes('-')) {
console.log(`Skipping recovery: ${clerkjsVersion} is a pre-release`);
return;
}
Comment on lines +138 to +141
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Pre-release check should also validate clerkUiVersion.

The current check only validates clerkjsVersion for pre-release markers. If clerkjsVersion is stable (e.g., 6.1.0) but clerkUiVersion is a pre-release (e.g., 1.0.0-canary.5), the recovery would proceed and dispatch with a pre-release UI version to downstream repos.

🐛 Proposed fix to check both versions
             // Only recover stable releases
-            if (clerkjsVersion.includes('-')) {
-              console.log(`Skipping recovery: ${clerkjsVersion} is a pre-release`);
+            if (clerkjsVersion.includes('-') || clerkUiVersion.includes('-')) {
+              console.log(`Skipping recovery: clerkjs=${clerkjsVersion}, ui=${clerkUiVersion} contains a pre-release`);
               return;
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/release.yml around lines 138 - 141, The pre-release guard
only checks clerkjsVersion; update the logic around the if block that references
clerkjsVersion to also inspect clerkUiVersion for pre-release markers (e.g., a
hyphen) and skip the recovery if either version is a pre-release; adjust the
console.log to indicate which version(s) caused the skip (use the existing
clerkjsVersion and clerkUiVersion identifiers so the message shows the offending
version(s)).


// Check if either version was actually published to npm
function isPublished(name, version) {
try {
return execSync(`npm view ${name}@${version} version`, { encoding: 'utf8' }).trim() === version;
} catch {
return false;
}
}

const clerkjsPublished = isPublished('@clerk/clerk-js', clerkjsVersion);
const clerkUiPublished = isPublished('@clerk/ui', clerkUiVersion);

if (!clerkjsPublished && !clerkUiPublished) {
console.log('Neither @clerk/clerk-js nor @clerk/ui were published to npm, no recovery needed');
return;
}

const published = [
clerkjsPublished && `@clerk/clerk-js@${clerkjsVersion}`,
clerkUiPublished && `@clerk/ui@${clerkUiVersion}`,
].filter(Boolean).join(', ');
core.warning(`Recovery: ${published} published to npm but downstream repos were not notified. Dispatching now.`);

const preMode = require("fs").existsSync("./.changeset/pre.json");
if (preMode) {
core.warning("Changeset in pre-mode, skipping recovery dispatch");
return;
}

const nextjsVersion = require('./packages/nextjs/package.json').version;

const dispatches = [
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'sdk-infra-workers',
workflow_id: 'update-pkg-versions.yml',
ref: 'main',
inputs: { clerkjsVersion, clerkUiVersion }
}),
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'dashboard',
workflow_id: 'prepare-nextjs-sdk-update.yml',
ref: 'main',
inputs: { version: nextjsVersion }
}),
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'clerk-docs',
workflow_id: 'typedoc.yml',
ref: 'main',
}),
];
await Promise.all(dispatches);
core.notice('Recovery dispatch completed successfully');

- name: Generate notification payload
id: notification
if: steps.changesets.outputs.published == 'true'
Expand Down
Loading