|
73 | 73 | NPM_CONFIG_PROVENANCE: true |
74 | 74 |
|
75 | 75 | - name: Trigger workflows on related repos |
| 76 | + id: trigger |
76 | 77 | if: steps.changesets.outputs.published == 'true' |
77 | 78 | uses: actions/github-script@v7 |
78 | 79 | with: |
@@ -114,6 +115,80 @@ jobs: |
114 | 115 | core.warning("Changeset in pre-mode should not prepare a ClerkJS production release") |
115 | 116 | } |
116 | 117 |
|
| 118 | + # Recovery: if the changesets action published to npm but then failed |
| 119 | + # (e.g. git push --follow-tags error), the `published` output is never |
| 120 | + # set and downstream repos are not notified. This step detects that |
| 121 | + # scenario by checking npm for the local package version and dispatches |
| 122 | + # if the packages are already live. |
| 123 | + - name: Recover downstream notifications |
| 124 | + if: always() && steps.changesets.conclusion == 'failure' |
| 125 | + uses: actions/github-script@v7 |
| 126 | + with: |
| 127 | + result-encoding: string |
| 128 | + retries: 3 |
| 129 | + retry-exempt-status-codes: 400,401 |
| 130 | + github-token: ${{ secrets.CLERK_COOKIE_PAT }} |
| 131 | + script: | |
| 132 | + const { execSync } = require('child_process'); |
| 133 | +
|
| 134 | + const clerkjsVersion = require('./packages/clerk-js/package.json').version; |
| 135 | +
|
| 136 | + // Only recover stable releases |
| 137 | + if (clerkjsVersion.includes('-')) { |
| 138 | + console.log(`Skipping recovery: ${clerkjsVersion} is a pre-release`); |
| 139 | + return; |
| 140 | + } |
| 141 | +
|
| 142 | + // Check if this version was actually published to npm |
| 143 | + let npmVersion; |
| 144 | + try { |
| 145 | + npmVersion = execSync(`npm view @clerk/clerk-js@${clerkjsVersion} version`, { encoding: 'utf8' }).trim(); |
| 146 | + } catch { |
| 147 | + console.log(`Version ${clerkjsVersion} not found on npm, no recovery needed`); |
| 148 | + return; |
| 149 | + } |
| 150 | +
|
| 151 | + if (npmVersion !== clerkjsVersion) { |
| 152 | + console.log(`Version mismatch: local=${clerkjsVersion}, npm=${npmVersion}`); |
| 153 | + return; |
| 154 | + } |
| 155 | +
|
| 156 | + core.warning(`Recovery: @clerk/clerk-js@${clerkjsVersion} was published to npm but downstream repos were not notified. Dispatching now.`); |
| 157 | +
|
| 158 | + const preMode = require("fs").existsSync("./.changeset/pre.json"); |
| 159 | + if (preMode) { |
| 160 | + core.warning("Changeset in pre-mode, skipping recovery dispatch"); |
| 161 | + return; |
| 162 | + } |
| 163 | +
|
| 164 | + const clerkUiVersion = require('./packages/ui/package.json').version; |
| 165 | + const nextjsVersion = require('./packages/nextjs/package.json').version; |
| 166 | +
|
| 167 | + const dispatches = [ |
| 168 | + github.rest.actions.createWorkflowDispatch({ |
| 169 | + owner: 'clerk', |
| 170 | + repo: 'sdk-infra-workers', |
| 171 | + workflow_id: 'update-pkg-versions.yml', |
| 172 | + ref: 'main', |
| 173 | + inputs: { clerkjsVersion, clerkUiVersion } |
| 174 | + }), |
| 175 | + github.rest.actions.createWorkflowDispatch({ |
| 176 | + owner: 'clerk', |
| 177 | + repo: 'dashboard', |
| 178 | + workflow_id: 'prepare-nextjs-sdk-update.yml', |
| 179 | + ref: 'main', |
| 180 | + inputs: { version: nextjsVersion } |
| 181 | + }), |
| 182 | + github.rest.actions.createWorkflowDispatch({ |
| 183 | + owner: 'clerk', |
| 184 | + repo: 'clerk-docs', |
| 185 | + workflow_id: 'typedoc.yml', |
| 186 | + ref: 'main', |
| 187 | + }), |
| 188 | + ]; |
| 189 | + await Promise.all(dispatches); |
| 190 | + core.notice('Recovery dispatch completed successfully'); |
| 191 | +
|
117 | 192 | - name: Generate notification payload |
118 | 193 | id: notification |
119 | 194 | if: steps.changesets.outputs.published == 'true' |
|
0 commit comments