kimi-code/.github/workflows/release.yml
qer d1c3b048fd
ci: publish core releases from isolated release branches (#4217)
* ci: publish core releases from isolated release branches

* ci: simplify release recovery to the CLI package

* ci: publish VS Code from approved release commits

* test: await release test registration for type-aware lint

* test: avoid assuming order of independent tower events

* ci: limit release migration to existing publishing flow
2026-10-14 22:35:59 +08:00

208 lines
6.4 KiB
YAML

name: Release
on:
push:
branches: ['release/*']
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: false
jobs:
version:
if: github.repository_owner == 'MoonshotAI' && startsWith(github.ref, 'refs/heads/release/')
concurrency:
group: release-version-${{ github.ref }}
cancel-in-progress: false
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- uses: changesets/action@v1
id: version
with:
version: pnpm run version:release
commit: 'ci: release packages'
title: 'ci: release packages'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check version PR
if: steps.version.outputs.pullRequestNumber != ''
env:
GH_TOKEN: ${{ github.token }}
VERSION_BRANCH: changeset-release/${{ github.ref_name }}
run: gh workflow run ci.yml --ref "$VERSION_BRANCH"
candidate:
if: github.repository_owner == 'MoonshotAI' && github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
pull-requests: read
actions: read
checks: read
outputs:
publish: ${{ steps.trigger.outputs.publish }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
- name: Wait for merged version commit CI
id: trigger
env:
GH_TOKEN: ${{ github.token }}
run: node scripts/release-trigger.mjs
vscode:
needs: candidate
if: needs.candidate.outputs.publish == 'true'
permissions:
contents: read
uses: ./.github/workflows/vscode-publish.yml
secrets:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}
release:
name: Release
runs-on: ubuntu-latest
needs: candidate
if: needs.candidate.outputs.publish == 'true'
outputs:
packages_published: ${{ steps.changesets.outputs.published }}
kimi_native_release: ${{ steps.kimi-release.outputs.should_publish }}
kimi_release_tag: ${{ steps.kimi-release.outputs.tag }}
permissions:
contents: write
pull-requests: write
id-token: write # Required for NPM Trusted Publishing (OIDC)
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Upgrade npm for Trusted Publishing
run: npm install -g npm@11
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Generate Kimi Code built-in catalog
shell: bash
run: |
CATALOG_FILE="$RUNNER_TEMP/kimi-code-built-in-catalog.json"
node apps/kimi-code/scripts/update-catalog.mjs --out "$CATALOG_FILE"
echo "KIMI_CODE_BUILT_IN_CATALOG_FILE=$CATALOG_FILE" >> "$GITHUB_ENV"
- name: Build packages
run: pnpm build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm changeset publish
version: pnpm run version:release
commit: "ci: release packages"
title: "ci: release packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# NPM_TOKEN is not needed with Trusted Publishing (OIDC)
- name: Resolve Kimi Code native release
if: steps.changesets.outputs.published == 'true'
id: kimi-release
run: node apps/kimi-code/scripts/native/resolve-release.mjs
env:
CHANGESETS_PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
native-artifacts:
name: Native release artifact
needs: release
if: needs.release.outputs.kimi_native_release == 'true'
uses: ./.github/workflows/_native-build.yml
with:
upload-artifact-prefix: kimi-code-native
retention-days: 7
sign-macos: true
sign-windows: true
secrets:
APPLE_CERTIFICATE_P12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_NOTARIZATION_KEY_P8: ${{ secrets.APPLE_NOTARIZATION_KEY_P8 }}
APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
publish-native-assets:
name: Publish native release assets
needs:
- release
- native-artifacts
if: needs.release.outputs.kimi_native_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download native artifacts
uses: actions/download-artifact@v8
with:
pattern: kimi-code-native-*
path: dist-native-release
merge-multiple: true
- name: Produce manifest.json
env:
RELEASE_TAG: ${{ needs.release.outputs.kimi_release_tag }}
run: node apps/kimi-code/scripts/native/produce-manifest.mjs dist-native-release "$RELEASE_TAG"
- name: Upload assets to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.release.outputs.kimi_release_tag }}
run: gh release upload "$RELEASE_TAG" dist-native-release/* --clobber
deploy-docs:
needs: publish-native-assets
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Deploy existing main documentation
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh workflow run docs-deploy.yml --ref main