|
38 | 38 | echo "Skipping non-stable SDK version: $version" |
39 | 39 | exit 0 |
40 | 40 | fi |
| 41 | + # A just-published version can take a few minutes to become installable. |
| 42 | + for attempt in $(seq 1 30); do |
| 43 | + if [[ "$(npm view "@onkernel/sdk@$version" version 2>/dev/null)" == "$version" ]]; then |
| 44 | + break |
| 45 | + fi |
| 46 | + if [[ "$attempt" == 30 ]]; then |
| 47 | + echo "::error::@onkernel/sdk@$version is not available on npm after 15 minutes." |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + sleep 30 |
| 51 | + done |
41 | 52 | echo "version=$version" >> "$GITHUB_OUTPUT" |
42 | 53 | echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
43 | 54 |
|
@@ -104,14 +115,21 @@ jobs: |
104 | 115 | if git show-ref --verify --quiet "refs/remotes/origin/$UPDATE_BRANCH"; then |
105 | 116 | echo "update_sha=$(git rev-parse "origin/$UPDATE_BRANCH")" >> "$GITHUB_OUTPUT" |
106 | 117 | git switch --track "origin/$UPDATE_BRANCH" |
107 | | - if ! git merge origin/main --no-edit; then |
108 | | - echo "::error::$UPDATE_BRANCH conflicts with main. Resolve the conflicts on that branch, or delete it to start fresh, then rerun this workflow." |
109 | | - exit 1 |
| 118 | + if ! git rebase origin/main; then |
| 119 | + git rebase --abort |
| 120 | + # The agent covers everything since main's SDK version, so a bot-only |
| 121 | + # branch can be regenerated from main. Human commits must be kept. |
| 122 | + if git log --no-merges --format=%ae "origin/main..origin/$UPDATE_BRANCH" \ |
| 123 | + | grep -qvxF '260533166+kernel-internal[bot]@users.noreply.github.com'; then |
| 124 | + echo "::error::$UPDATE_BRANCH has human commits that conflict with main. Resolve the conflicts on that branch, then rerun this workflow." |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + echo "::warning::$UPDATE_BRANCH conflicts with main; regenerating it from main." |
| 128 | + git switch -C "$UPDATE_BRANCH" origin/main |
110 | 129 | fi |
111 | 130 | else |
112 | 131 | git switch -c "$UPDATE_BRANCH" origin/main |
113 | 132 | fi |
114 | | - echo "agent_base=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
115 | 133 |
|
116 | 134 | old_version=$(jq -er '.dependencies["@onkernel/sdk"]' package.json) |
117 | 135 | if [[ "$old_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && |
@@ -203,9 +221,9 @@ jobs: |
203 | 221 | id: snapshot |
204 | 222 | working-directory: mcp |
205 | 223 | env: |
206 | | - AGENT_BASE: ${{ steps.prepare.outputs.agent_base }} |
| 224 | + MAIN_SHA: ${{ steps.prepare.outputs.main_sha }} |
207 | 225 | run: | |
208 | | - git reset -q --soft "$AGENT_BASE" |
| 226 | + git reset -q --soft "$MAIN_SHA" |
209 | 227 | git add -A |
210 | 228 | git diff --cached --name-only --no-renames -z \ |
211 | 229 | | bash ../.github/scripts/mcp-update-disallowed-paths.sh > "$RUNNER_TEMP/excluded-paths" |
@@ -284,12 +302,7 @@ jobs: |
284 | 302 | run: | |
285 | 303 | git config user.name 'kernel-internal[bot]' |
286 | 304 | git config user.email '260533166+kernel-internal[bot]@users.noreply.github.com' |
287 | | - if [[ -n "$UPDATE_SHA" ]]; then |
288 | | - git switch -c "$UPDATE_BRANCH" "$UPDATE_SHA" |
289 | | - git merge --no-edit "$MAIN_SHA" |
290 | | - else |
291 | | - git switch -c "$UPDATE_BRANCH" "$MAIN_SHA" |
292 | | - fi |
| 305 | + git switch -c "$UPDATE_BRANCH" "$MAIN_SHA" |
293 | 306 | git apply --index "$RUNNER_TEMP/mcp-coverage-update/changes.patch" |
294 | 307 | git diff --cached --name-only --no-renames -z \ |
295 | 308 | | bash ../.github/scripts/mcp-update-disallowed-paths.sh > "$RUNNER_TEMP/disallowed-paths" |
@@ -325,7 +338,7 @@ jobs: |
325 | 338 | exit 0 |
326 | 339 | fi |
327 | 340 | gh auth setup-git |
328 | | - git push origin "$UPDATE_BRANCH" |
| 341 | + git push --force-with-lease="$UPDATE_BRANCH:$UPDATE_SHA" origin "$UPDATE_BRANCH" |
329 | 342 |
|
330 | 343 | body="$RUNNER_TEMP/mcp-coverage-pr.md" |
331 | 344 | { |
|
0 commit comments