Skip to content
Closed
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 @@
---
---
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,91 @@ 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
const preReleases = [
clerkjsVersion.includes('-') && `@clerk/clerk-js@${clerkjsVersion}`,
clerkUiVersion.includes('-') && `@clerk/ui@${clerkUiVersion}`,
].filter(Boolean);
if (preReleases.length > 0) {
console.log(`Skipping recovery: ${preReleases.join(', ')} is a pre-release`);
return;
}

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

// 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 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