Skip to content

Commit 9e680d0

Browse files
authored
ci: speed up the release loop (#18)
Skip the full build when only opening the version PR, skip Release on unrelated main pushes, and skip CI/Nix on changeset-release/main so auto-merge is not blocked for four minutes. Stop the double publish (PAT merges already emit push; only keep the pull_request fallback for github-actions[bot] merges) and serialize Release on one concurrency group. Leave checkout credentials unset so changesets/action pushes the version branch with CHANGESETS_TOKEN instead of the job token. The job token made those updates github-actions[bot] and parked CI in action_required.
1 parent a09f90e commit 9e680d0

3 files changed

Lines changed: 66 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ on:
99
permissions:
1010
contents: read
1111

12+
# Version PRs only bump package.json / CHANGELOG — the same commits already
13+
# passed CI on main. Skip the heavy jobs so auto-merge is not blocked for ~4
14+
# minutes (or stuck in action_required). The aggregate "CI" job still runs
15+
# and is the required check.
1216
jobs:
1317
build:
1418
runs-on: ubuntu-latest
19+
if: github.head_ref != 'changeset-release/main'
1520

1621
steps:
1722
- uses: actions/checkout@v4
@@ -30,6 +35,7 @@ jobs:
3035

3136
test:
3237
runs-on: ubuntu-latest
38+
if: github.head_ref != 'changeset-release/main'
3339
strategy:
3440
fail-fast: false
3541
matrix:
@@ -52,6 +58,7 @@ jobs:
5258
# does not execute it; it needs its own job.
5359
test-pi-tui:
5460
runs-on: ubuntu-latest
61+
if: github.head_ref != 'changeset-release/main'
5562

5663
steps:
5764
- uses: actions/checkout@v4
@@ -71,6 +78,7 @@ jobs:
7178
# the extension selects through the rollback env var.
7279
test-vscode-legacy:
7380
runs-on: ubuntu-latest
81+
if: github.head_ref != 'changeset-release/main'
7482

7583
steps:
7684
- uses: actions/checkout@v4
@@ -110,6 +118,7 @@ jobs:
110118

111119
lint:
112120
runs-on: ubuntu-latest
121+
if: github.head_ref != 'changeset-release/main'
113122

114123
steps:
115124
- uses: actions/checkout@v4
@@ -127,6 +136,7 @@ jobs:
127136

128137
typecheck:
129138
runs-on: ubuntu-latest
139+
if: github.head_ref != 'changeset-release/main'
130140

131141
steps:
132142
- uses: actions/checkout@v4
@@ -157,6 +167,7 @@ jobs:
157167
# GitHub names the workflow-level check after the workflow, but the PR merge
158168
# machinery matches required contexts against job names here, so an explicit
159169
# job named CI is needed for the required check to be satisfiable.
170+
# Skipped children (version PRs) are success — only failure/cancelled fail.
160171
CI:
161172
runs-on: ubuntu-latest
162173
needs: [build, test, test-pi-tui, lint, typecheck]

.github/workflows/nix-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
check-workspace-sync:
1717
name: Check flake.nix workspace sync
1818
runs-on: ubuntu-latest
19+
if: github.head_ref != 'changeset-release/main'
1920

2021
steps:
2122
- name: Checkout
@@ -90,6 +91,7 @@ jobs:
9091
name: nix build .#kimi-code
9192
needs: check-workspace-sync
9293
runs-on: ubuntu-latest
94+
if: github.head_ref != 'changeset-release/main'
9395

9496
steps:
9597
- name: Checkout

.github/workflows/release.yml

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ on:
44
push:
55
branches:
66
- main
7-
# The version PR is merged via auto-merge, which does not emit a push event;
8-
# fire the release from the merge's pull_request closed event instead.
7+
# Fallback only: a GITHUB_TOKEN merge of the version PR does not emit push.
8+
# PAT merges (the usual path) already fire the push event above — do not
9+
# also handle those here or two publishes race.
910
pull_request:
1011
types: [closed]
1112
branches:
1213
- main
1314

14-
concurrency: ${{ github.workflow }}-${{ github.ref }}
15+
# One publish at a time. Do not cancel an in-flight npm publish.
16+
concurrency:
17+
group: release-${{ github.repository }}
18+
cancel-in-progress: false
1519

1620
jobs:
1721
release:
@@ -22,7 +26,8 @@ jobs:
2226
(github.event_name == 'push' ||
2327
(github.event_name == 'pull_request' &&
2428
github.event.pull_request.merged == true &&
25-
github.event.pull_request.head.ref == 'changeset-release/main'))
29+
github.event.pull_request.head.ref == 'changeset-release/main' &&
30+
github.event.pull_request.merged_by.login == 'github-actions[bot]'))
2631
outputs:
2732
packages_published: ${{ steps.changesets.outputs.published }}
2833
kimi_native_release: ${{ steps.kimi-release.outputs.should_publish }}
@@ -39,41 +44,84 @@ jobs:
3944
# On pull_request (closed) events the checkout defaults to the PR
4045
# merge ref; always base the release on main's post-merge state.
4146
ref: main
47+
# checkout's default extraheader uses the job GITHUB_TOKEN and beats
48+
# changesets/action's .netrc PAT, so version-PR updates are pushed
49+
# as github-actions[bot] and CI sits in action_required. Leave
50+
# credentials unset; the action writes .netrc from CHANGESETS_TOKEN.
51+
persist-credentials: false
52+
53+
- name: Detect release mode
54+
id: mode
55+
env:
56+
EVENT_NAME: ${{ github.event_name }}
57+
run: |
58+
set -euo pipefail
59+
has_changesets=false
60+
if find .changeset -maxdepth 1 -name '*.md' ! -name 'README.md' | grep -q .; then
61+
has_changesets=true
62+
fi
63+
64+
is_release_merge=false
65+
subject=$(git log -1 --format=%s)
66+
if [ "$EVENT_NAME" = "pull_request" ]; then
67+
is_release_merge=true
68+
elif [[ "$subject" == *"changeset-release/main"* ]]; then
69+
is_release_merge=true
70+
elif [ "$subject" = "ci: release packages" ]; then
71+
is_release_merge=true
72+
fi
73+
74+
if [ "$has_changesets" = true ]; then
75+
echo "mode=version" >> "$GITHUB_OUTPUT"
76+
elif [ "$is_release_merge" = true ]; then
77+
echo "mode=publish" >> "$GITHUB_OUTPUT"
78+
else
79+
echo "mode=skip" >> "$GITHUB_OUTPUT"
80+
fi
81+
echo "mode has_changesets=$has_changesets is_release_merge=$is_release_merge subject=$subject"
4282
4383
- name: Setup pnpm
84+
if: steps.mode.outputs.mode != 'skip'
4485
uses: pnpm/action-setup@v6
4586

4687
- name: Setup Node.js
88+
if: steps.mode.outputs.mode != 'skip'
4789
uses: actions/setup-node@v6
4890
with:
4991
node-version-file: .nvmrc
5092
cache: "pnpm"
5193
registry-url: "https://registry.npmjs.org"
5294

5395
- name: Upgrade npm for Trusted Publishing
96+
if: steps.mode.outputs.mode == 'publish'
5497
run: npm install -g npm@11
5598

5699
- name: Install dependencies
100+
if: steps.mode.outputs.mode != 'skip'
57101
run: pnpm install --frozen-lockfile
58102

59103
- name: Generate Kimi Code built-in catalog
104+
if: steps.mode.outputs.mode == 'publish'
60105
shell: bash
61106
run: |
62107
CATALOG_FILE="$RUNNER_TEMP/kimi-code-built-in-catalog.json"
63108
node apps/kimi-code/scripts/update-catalog.mjs --out "$CATALOG_FILE"
64109
echo "KIMI_CODE_BUILT_IN_CATALOG_FILE=$CATALOG_FILE" >> "$GITHUB_ENV"
65110
66111
- name: Build packages
112+
if: steps.mode.outputs.mode == 'publish'
67113
run: pnpm build
68114

69115
- name: Create Release Pull Request or Publish to npm
70116
id: changesets
117+
if: steps.mode.outputs.mode != 'skip'
71118
uses: changesets/action@v1
72119
with:
73120
publish: pnpm changeset publish
74121
version: pnpm run version:release
75122
commit: "ci: release packages"
76123
title: "ci: release packages"
124+
commitMode: git-cli
77125
# Use the maintainer's PAT so the version PR is authored by a real
78126
# account: PRs created by github-actions[bot] always require manual
79127
# workflow approval (the bot has no contribution history), which
@@ -93,7 +141,7 @@ jobs:
93141
# branch protection requiring status checks); changesets/action has no
94142
# such input of its own.
95143
- name: Enable auto-merge on the version PR
96-
if: steps.changesets.outputs.pullRequestNumber != ''
144+
if: steps.mode.outputs.mode != 'skip' && steps.changesets.outputs.pullRequestNumber != ''
97145
run: gh pr merge --repo "$GITHUB_REPOSITORY" --merge --auto "${{ steps.changesets.outputs.pullRequestNumber }}"
98146
env:
99147
# Auto-merge with the maintainer's PAT: merges performed with the

0 commit comments

Comments
 (0)