mirror of
https://github.com/ranxianglei/billion-context.git
synced 2026-11-24 20:20:45 +08:00
Follow-up to the v0.1.192 carve-out (#2664): the bugfix channel shipped with only its embedded pre-flight (typecheck+test+build) — no e2e lane ever ran on the publish sha, because no PR existed and no e2e workflow triggers on bugfix-release/** pushes. Policy (2026-10-10): no matter the release channel, the COMPLETE CI lane set must be green at the exact publish sha before npm publish. - new scripts/release-ci-gate.mjs: --dispatch: idempotently workflow_dispatch every required lane that has no run at the publish sha (or a green run at an EXTRA_MATCH_SHAS, e.g. the PR head — same semantics as branch-protection required checks, so routine PR-based releases pay zero extra CI); --wait: block until every lane's latest run at the publish sha is success; any red lane / timeout / un-dispatchable lane ⇒ exit 1, publish step never runs (fail-safe). - release.yml / release-kernel.yml: dispatch early + gate before Create tag, gated on is_release; EXTRA_MATCH_SHAS=HEAD^2 reuses PR-head runs. - release-bugfix.yml: dispatch before the pre-flight (lanes run in parallel with it) + gate after it; +actions:write. - release-manual.yml: direct path (GITHUB_TOKEN push fires no events, nothing runs CI on the release commit) gets dispatch+gate before Create tag; fallback path is already gated via release.yml after merge. - required set (override with REQUIRED_CI_WORKFLOWS): ci.yml, ci-e2e.yml, ci-e2e-fake.yml, ci-e2e-dsh.yml, ci-e2e-dsh-native.yml, ci-e2e-codex-persona.yml, ci-e2e-native.yml, ci-e2e-native-opencode.yml, ci-e2e-pi-ws.yml - tests/release-ci-gate.test.ts: 8 regression tests against an inline mock of the GitHub Actions API (no network, no token).
138 lines
5.5 KiB
YAML
138 lines
5.5 KiB
YAML
name: Release Kernel
|
|
|
|
# Independent acp-kernel releases from this repo (#2092). Triggered by merging
|
|
# a *_release-kernel-v* branch (or a direct "release kernel v{VERSION}" commit
|
|
# on master). The branch pattern is mutually exclusive with bili's
|
|
# *_release-v* pattern in every direction (merge-branch match, direct commit
|
|
# message, version-guard, kernel-guard), so the two release flows never
|
|
# cross-trigger. Tag namespace: kernel-v* (bili tags stay bare v*).
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
release-kernel:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
actions: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
registry-url: https://registry.npmjs.org
|
|
|
|
- name: Check if kernel release branch merge
|
|
id: check
|
|
run: |
|
|
COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
MERGE_BRANCH=$(echo "$COMMIT_MSG" | sed -n 's/^Merge pull request #[0-9]* from [^/]*\/\(.*\)$/\1/p' || echo "")
|
|
if echo "$MERGE_BRANCH" | grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2}_release-kernel-v'; then
|
|
echo "is_release=true" >> $GITHUB_OUTPUT
|
|
elif echo "$COMMIT_MSG" | grep -qE '^release kernel v[0-9]'; then
|
|
echo "is_release=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "is_release=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Full CI dispatch (missing lanes, publish sha)
|
|
# Policy (2026-10-10, after the v0.1.192 carve-out): every release
|
|
# channel must run the COMPLETE CI set at the exact publish sha before
|
|
# npm publish. This merge already ran all lanes as a PR — dispatch only
|
|
# whatever has no run here (idempotent); the Full CI gate step before
|
|
# Create tag blocks publish until all lanes are green. EXTRA_MATCH_SHAS
|
|
# reuses the PR-head green runs (HEAD^2), so a normal PR release pays
|
|
# zero extra CI — same semantics as branch-protection required checks.
|
|
if: steps.check.outputs.is_release == 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
GITHUB_SHA="$(git rev-parse HEAD)"
|
|
EXTRA_MATCH_SHAS="$(git rev-parse HEAD^2 2>/dev/null || true)"
|
|
export GITHUB_SHA EXTRA_MATCH_SHAS
|
|
node scripts/release-ci-gate.mjs --dispatch
|
|
|
|
- name: Setup
|
|
if: steps.check.outputs.is_release == 'true'
|
|
run: npm ci
|
|
|
|
- name: Build and test
|
|
if: steps.check.outputs.is_release == 'true'
|
|
# Full bili gate first: the kernel ships inside bili's bundle, so a
|
|
# kernel release rides on a fully green tree. Then the kernel's own
|
|
# suite against its TS source.
|
|
env:
|
|
ACP_TEST_CLAUDE_NATIVE: "1"
|
|
run: |
|
|
npm run typecheck
|
|
npm test
|
|
npm run build
|
|
npm --prefix kernel run typecheck
|
|
npm --prefix kernel test
|
|
npm --prefix kernel run build
|
|
|
|
- name: Read kernel version
|
|
if: steps.check.outputs.is_release == 'true'
|
|
id: version
|
|
run: |
|
|
V="$(node -p "require('./kernel/package.json').version")"
|
|
if [ -z "$V" ] || [ "$V" = "undefined" ]; then
|
|
echo "::error::could not read kernel/package.json version"
|
|
exit 1
|
|
fi
|
|
echo "version=$V" >> $GITHUB_OUTPUT
|
|
|
|
- name: Check if prerelease
|
|
if: steps.check.outputs.is_release == 'true'
|
|
id: pre
|
|
run: |
|
|
if echo "${{ steps.version.outputs.version }}" | grep -q '-'; then
|
|
echo "tag=dev" >> $GITHUB_OUTPUT
|
|
echo "prerelease=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=latest" >> $GITHUB_OUTPUT
|
|
echo "prerelease=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Full CI gate (all lanes green at this sha)
|
|
# Hard precondition for publish: every required lane green at the
|
|
# publish sha (or reused green PR-head run). Any red lane or timeout
|
|
# ⇒ release fails, nothing is published.
|
|
if: steps.check.outputs.is_release == 'true'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
CI_GATE_TIMEOUT_MIN: "60"
|
|
run: |
|
|
GITHUB_SHA="$(git rev-parse HEAD)"
|
|
EXTRA_MATCH_SHAS="$(git rev-parse HEAD^2 2>/dev/null || true)"
|
|
export GITHUB_SHA EXTRA_MATCH_SHAS
|
|
node scripts/release-ci-gate.mjs --wait
|
|
|
|
- name: Create tag
|
|
if: steps.check.outputs.is_release == 'true'
|
|
run: |
|
|
git tag "kernel-v${{ steps.version.outputs.version }}" || true
|
|
git push origin "kernel-v${{ steps.version.outputs.version }}" || true
|
|
|
|
- name: Publish
|
|
if: steps.check.outputs.is_release == 'true'
|
|
run: cd kernel && npm publish --tag ${{ steps.pre.outputs.tag }} --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Create GitHub Release
|
|
if: steps.check.outputs.is_release == 'true'
|
|
run: |
|
|
VER="${{ steps.version.outputs.version }}"
|
|
curl -sS -f -X POST \
|
|
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Accept: application/vnd.github+json" \
|
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
"https://api.github.com/repos/${{ github.repository }}/releases" \
|
|
-d "{\"tag_name\":\"kernel-v${VER}\",\"name\":\"acp-kernel v${VER}\",\"prerelease\":${{ steps.pre.outputs.prerelease }},\"generate_release_notes\":true}"
|