mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-31 01:37:28 +08:00
refactor: integrate vscode build into standard publish workflow
- Split vscode publish script into build.ts and publish.ts
- Build script copies CLI binaries from dist artifacts instead of downloading
- VSIX packages renamed to kilo-vscode-{target}.vsix
- Added build-vscode job to publish.yml workflow
- VSCode publishing now part of main publish flow
- Removed standalone publish-vscode.yml workflow
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
name: publish-vscode
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
cli_version:
|
||||
description: "CLI release version to use (e.g. v1.0.21, or 'latest')"
|
||||
required: false
|
||||
type: string
|
||||
default: "latest"
|
||||
push:
|
||||
tags:
|
||||
- "vscode-v*.*.*"
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
|
||||
- name: Install @vscode/vsce
|
||||
run: bun install -g @vscode/vsce
|
||||
|
||||
- name: Publish all targets
|
||||
run: bun script/publish.ts
|
||||
working-directory: ./packages/kilo-vscode
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
|
||||
OPENVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
|
||||
KILO_CLI_VERSION: ${{ inputs.cli_version || 'latest' }}
|
||||
@@ -87,6 +87,35 @@ jobs:
|
||||
outputs:
|
||||
version: ${{ needs.version.outputs.version }}
|
||||
|
||||
build-vscode:
|
||||
needs: build-cli
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
if: github.repository == 'Kilo-Org/kilo'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
|
||||
- name: Install @vscode/vsce
|
||||
run: bun install -g @vscode/vsce
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: kilo-cli
|
||||
path: packages/opencode/dist
|
||||
|
||||
- name: Build VSIX packages
|
||||
run: bun script/build.ts
|
||||
working-directory: ./packages/kilo-vscode
|
||||
env:
|
||||
CLI_DIST_DIR: ../../packages/opencode/dist
|
||||
KILO_VERSION: ${{ needs.build-cli.outputs.version }}
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: kilo-vscode
|
||||
path: packages/kilo-vscode/out
|
||||
|
||||
# build-tauri:
|
||||
# needs:
|
||||
# - build-cli
|
||||
@@ -207,6 +236,7 @@ jobs:
|
||||
needs:
|
||||
- version
|
||||
- build-cli
|
||||
- build-vscode
|
||||
# - build-tauri
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
@@ -246,6 +276,14 @@ jobs:
|
||||
name: kilo-cli
|
||||
path: packages/opencode/dist
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: kilo-vscode
|
||||
path: packages/kilo-vscode/out
|
||||
|
||||
- name: Install @vscode/vsce
|
||||
run: bun install -g @vscode/vsce
|
||||
|
||||
- name: Cache apt packages (AUR)
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
@@ -273,3 +311,5 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
|
||||
OPENVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bun
|
||||
import { $ } from "bun"
|
||||
import { join } from "node:path"
|
||||
import { existsSync, mkdirSync, rmSync, chmodSync } from "node:fs"
|
||||
|
||||
const packageJson = await Bun.file(join(import.meta.dir, "..", "package.json")).json()
|
||||
const version = packageJson.version
|
||||
|
||||
console.log(`Building VSCode extension version: ${version}`)
|
||||
|
||||
const cliDistDir = process.env.CLI_DIST_DIR || join(import.meta.dir, "..", "..", "opencode", "dist")
|
||||
console.log(`Using CLI dist directory: ${cliDistDir}`)
|
||||
|
||||
if (!existsSync(cliDistDir)) {
|
||||
throw new Error(`CLI dist directory not found: ${cliDistDir}`)
|
||||
}
|
||||
|
||||
const targets = [
|
||||
{ target: "linux-x64", cliDir: "@kilocode/cli-linux-x64", binary: "kilo" },
|
||||
{ target: "linux-arm64", cliDir: "@kilocode/cli-linux-arm64", binary: "kilo" },
|
||||
{ target: "alpine-x64", cliDir: "@kilocode/cli-linux-x64-musl", binary: "kilo" },
|
||||
{ target: "alpine-arm64", cliDir: "@kilocode/cli-linux-arm64-musl", binary: "kilo" },
|
||||
{ target: "darwin-x64", cliDir: "@kilocode/cli-darwin-x64", binary: "kilo" },
|
||||
{ target: "darwin-arm64", cliDir: "@kilocode/cli-darwin-arm64", binary: "kilo" },
|
||||
{ target: "win32-x64", cliDir: "@kilocode/cli-windows-x64", binary: "kilo.exe" },
|
||||
]
|
||||
|
||||
const binDir = join(import.meta.dir, "..", "bin")
|
||||
const distDir = join(import.meta.dir, "..", "dist")
|
||||
const outDir = join(import.meta.dir, "..", "out")
|
||||
|
||||
console.log("\n🧹 Cleaning up directories...")
|
||||
for (const dir of [binDir, distDir, outDir]) {
|
||||
if (existsSync(dir)) {
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
console.log(` ✓ Cleaned ${dir}`)
|
||||
}
|
||||
}
|
||||
|
||||
mkdirSync(outDir, { recursive: true })
|
||||
mkdirSync(distDir, { recursive: true })
|
||||
|
||||
console.log("\n📦 Compiling extension...")
|
||||
await $`bun run check-types`
|
||||
await $`bun run lint`
|
||||
await $`node ${join(import.meta.dir, "..", "esbuild.js")} --production`
|
||||
|
||||
for (const config of targets) {
|
||||
console.log(`\n🎯 Processing target: ${config.target}`)
|
||||
|
||||
if (existsSync(binDir)) {
|
||||
rmSync(binDir, { recursive: true, force: true })
|
||||
}
|
||||
mkdirSync(binDir, { recursive: true })
|
||||
|
||||
const sourceBinary = join(cliDistDir, config.cliDir, "bin", config.binary)
|
||||
const targetBinary = join(binDir, config.binary)
|
||||
|
||||
if (!existsSync(sourceBinary)) {
|
||||
throw new Error(`CLI binary not found at ${sourceBinary}`)
|
||||
}
|
||||
|
||||
console.log(` 📥 Copying binary from ${config.cliDir}/bin/${config.binary}...`)
|
||||
await $`cp ${sourceBinary} ${targetBinary}`
|
||||
|
||||
if (config.binary !== "kilo.exe") {
|
||||
chmodSync(targetBinary, 0o755)
|
||||
}
|
||||
|
||||
console.log(` ✅ Binary ready at ${targetBinary}`)
|
||||
|
||||
console.log(` 📦 Packaging .vsix for ${config.target}...`)
|
||||
const vsixPath = join(outDir, `kilo-vscode-${config.target}.vsix`)
|
||||
await $`vsce package --pre-release --no-dependencies --skip-license --target ${config.target} -o ${vsixPath} ${version}`.env(
|
||||
{
|
||||
...process.env,
|
||||
npm_config_ignore_scripts: "true",
|
||||
},
|
||||
)
|
||||
console.log(` ✅ Created ${vsixPath}`)
|
||||
}
|
||||
|
||||
console.log("\n✨ All VSIX packages built successfully!")
|
||||
@@ -1,125 +1,51 @@
|
||||
#!/usr/bin/env bun
|
||||
import { $ } from "bun"
|
||||
import { join } from "node:path"
|
||||
import { existsSync, mkdirSync, rmSync, chmodSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { existsSync } from "node:fs"
|
||||
import { Script } from "@opencode-ai/script"
|
||||
|
||||
const packageJson = await Bun.file(join(import.meta.dir, "..", "package.json")).json()
|
||||
const version = packageJson.version
|
||||
|
||||
console.log(`Publishing version: ${version}`)
|
||||
console.log(`Publishing VSCode extension version: ${version}`)
|
||||
|
||||
// Get release version from env or default to "latest"
|
||||
const releaseVersion = process.env.KILO_CLI_VERSION || "latest"
|
||||
console.log(`Using CLI release version: ${releaseVersion}`)
|
||||
const outDir = process.env.VSIX_DIR || join(import.meta.dir, "..", "out")
|
||||
console.log(`Using VSIX directory: ${outDir}`)
|
||||
|
||||
// Target platform configurations
|
||||
const targets = [
|
||||
{ target: "linux-x64", asset: "kilo-linux-x64.tar.gz", binary: "kilo" },
|
||||
{ target: "linux-arm64", asset: "kilo-linux-arm64.tar.gz", binary: "kilo" },
|
||||
{ target: "alpine-x64", asset: "kilo-linux-x64-musl.tar.gz", binary: "kilo" },
|
||||
{ target: "alpine-arm64", asset: "kilo-linux-arm64-musl.tar.gz", binary: "kilo" },
|
||||
{ target: "darwin-x64", asset: "kilo-darwin-x64.zip", binary: "kilo" },
|
||||
{ target: "darwin-arm64", asset: "kilo-darwin-arm64.zip", binary: "kilo" },
|
||||
{ target: "win32-x64", asset: "kilo-windows-x64.zip", binary: "kilo.exe" },
|
||||
]
|
||||
|
||||
const binDir = join(import.meta.dir, "..", "bin")
|
||||
const distDir = join(import.meta.dir, "..", "dist")
|
||||
const outDir = join(import.meta.dir, "..", "out")
|
||||
|
||||
// Clean up directories at start
|
||||
console.log("\n🧹 Cleaning up directories...")
|
||||
for (const dir of [binDir, distDir, outDir]) {
|
||||
if (existsSync(dir)) {
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
console.log(` ✓ Cleaned ${dir}`)
|
||||
}
|
||||
if (!existsSync(outDir)) {
|
||||
throw new Error(`VSIX directory not found: ${outDir}`)
|
||||
}
|
||||
|
||||
// Ensure directories exist
|
||||
mkdirSync(outDir, { recursive: true })
|
||||
mkdirSync(distDir, { recursive: true })
|
||||
const targets = ["linux-x64", "linux-arm64", "alpine-x64", "alpine-arm64", "darwin-x64", "darwin-arm64", "win32-x64"]
|
||||
|
||||
// Compile the extension once (platform-agnostic)
|
||||
console.log("\n📦 Compiling extension...")
|
||||
await $`bun run check-types`
|
||||
await $`bun run lint`
|
||||
await $`node ${join(import.meta.dir, "..", "esbuild.js")} --production`
|
||||
|
||||
// Process each target
|
||||
for (const config of targets) {
|
||||
console.log(`\n🎯 Processing target: ${config.target}`)
|
||||
|
||||
// Clean bin directory
|
||||
if (existsSync(binDir)) {
|
||||
rmSync(binDir, { recursive: true, force: true })
|
||||
const vsixFiles: string[] = []
|
||||
for (const target of targets) {
|
||||
const vsixPath = join(outDir, `kilo-vscode-${target}.vsix`)
|
||||
if (!existsSync(vsixPath)) {
|
||||
throw new Error(`VSIX file not found: ${vsixPath}`)
|
||||
}
|
||||
mkdirSync(binDir, { recursive: true })
|
||||
vsixFiles.push(vsixPath)
|
||||
}
|
||||
|
||||
// Download and extract binary
|
||||
console.log(` 📥 Downloading ${config.asset}...`)
|
||||
const tmpDir = join(tmpdir(), `kilo-cli-${config.target}-${Date.now()}`)
|
||||
mkdirSync(tmpDir, { recursive: true })
|
||||
console.log(`\nFound ${vsixFiles.length} VSIX files`)
|
||||
|
||||
try {
|
||||
const downloadUrl =
|
||||
releaseVersion === "latest"
|
||||
? `https://github.com/Kilo-Org/kilo/releases/latest/download/${config.asset}`
|
||||
: `https://github.com/Kilo-Org/kilo/releases/download/${releaseVersion}/${config.asset}`
|
||||
for (const target of targets) {
|
||||
const vsixPath = join(outDir, `kilo-vscode-${target}.vsix`)
|
||||
|
||||
const assetPath = join(tmpDir, config.asset)
|
||||
await $`curl -fsSL -o ${assetPath} ${downloadUrl}`
|
||||
|
||||
// Extract based on file type
|
||||
console.log(` 📂 Extracting binary...`)
|
||||
if (config.asset.endsWith(".tar.gz")) {
|
||||
await $`tar -xzf ${assetPath} -C ${tmpDir}`
|
||||
} else if (config.asset.endsWith(".zip")) {
|
||||
await $`unzip -q ${assetPath} -d ${tmpDir}`
|
||||
}
|
||||
|
||||
// Find and copy binary
|
||||
const extractedBinary = join(tmpDir, config.binary)
|
||||
const targetBinary = join(binDir, config.binary)
|
||||
|
||||
if (!existsSync(extractedBinary)) {
|
||||
throw new Error(`Binary not found at ${extractedBinary}`)
|
||||
}
|
||||
|
||||
await $`cp ${extractedBinary} ${targetBinary}`
|
||||
|
||||
// Set executable permissions (Unix-like systems)
|
||||
if (config.binary !== "kilo.exe") {
|
||||
chmodSync(targetBinary, 0o755)
|
||||
}
|
||||
|
||||
console.log(` ✅ Binary ready at ${targetBinary}`)
|
||||
} finally {
|
||||
// Cleanup temp directory
|
||||
rmSync(tmpDir, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
// Package for this target (skip prepublish to keep downloaded binary)
|
||||
console.log(` 📦 Packaging .vsix for ${config.target}...`)
|
||||
const vsixPath = join(outDir, `kilo-code-${config.target}.vsix`)
|
||||
await $`vsce package --pre-release --no-dependencies --skip-license --target ${config.target} -o ${vsixPath} ${version}`.env(
|
||||
{
|
||||
...process.env,
|
||||
npm_config_ignore_scripts: "true",
|
||||
},
|
||||
)
|
||||
console.log(` ✅ Created ${vsixPath}`)
|
||||
|
||||
// Publish for this target
|
||||
console.log(` 🚀 Publishing to VS Code Marketplace for ${config.target}...`)
|
||||
console.log(`\n🚀 Publishing ${target} to VS Code Marketplace...`)
|
||||
await $`vsce publish --pre-release --packagePath ${vsixPath}`
|
||||
console.log(` ✅ Published ${config.target}`)
|
||||
console.log(` ✅ Published ${target} to VS Code Marketplace`)
|
||||
|
||||
// Note: Open VSX publishing is commented out as it doesn't support prereleases
|
||||
// console.log("\n📤 Publishing to Open VSX...")
|
||||
// await $`npx ovsx publish ${vsixPath} --target ${config.target} -p ${process.env.OPENVSX_TOKEN}`
|
||||
// console.log("✅ Published to Open VSX!")
|
||||
// console.log(`\n📤 Publishing ${target} to Open VSX...`)
|
||||
// await $`npx ovsx publish ${vsixPath} --target ${target} -p ${process.env.OPENVSX_TOKEN}`
|
||||
// console.log(` ✅ Published ${target} to Open VSX`)
|
||||
}
|
||||
|
||||
if (Script.release) {
|
||||
console.log(`\n📤 Uploading VSIX files to GitHub release v${Script.version}...`)
|
||||
await $`gh release upload v${Script.version} ${vsixFiles} --clobber`
|
||||
console.log(` ✅ Uploaded all VSIX files to GitHub release`)
|
||||
}
|
||||
|
||||
console.log("\n✨ All targets published successfully!")
|
||||
|
||||
@@ -80,5 +80,8 @@ await import(`../packages/sdk/js/script/publish.ts`)
|
||||
console.log("\n=== plugin ===\n")
|
||||
await import(`../packages/plugin/script/publish.ts`)
|
||||
|
||||
console.log("\n=== vscode ===\n")
|
||||
await import(`../packages/kilo-vscode/script/publish.ts`)
|
||||
|
||||
const dir = new URL("..", import.meta.url).pathname
|
||||
process.chdir(dir)
|
||||
|
||||
Reference in New Issue
Block a user