mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
Merge pull request #8599 from Kilo-Org/feat/cli-npm-prerelease
feat(cli): publish CLI as npm prerelease when pre_release flag is set
This commit is contained in:
@@ -23,7 +23,7 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
pre_release:
|
||||
description: "Publish as pre-release (VS Code marketplace)"
|
||||
description: "Publish as pre-release (VS Code marketplace + npm rc channel)"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
@@ -58,6 +58,7 @@ jobs:
|
||||
GH_REPO: ${{ github.repository }}
|
||||
KILO_BUMP: ${{ inputs.bump }}
|
||||
KILO_VERSION: ${{ inputs.version }}
|
||||
KILO_PRE_RELEASE: ${{ inputs.pre_release }}
|
||||
KILO_API_KEY: ${{ secrets.KILO_API_KEY }}
|
||||
KILO_ORG_ID: ${{ secrets.KILO_ORG_ID }}
|
||||
outputs:
|
||||
@@ -83,6 +84,7 @@ jobs:
|
||||
env:
|
||||
KILO_VERSION: ${{ needs.version.outputs.version }}
|
||||
KILO_RELEASE: ${{ needs.version.outputs.release }}
|
||||
KILO_PRE_RELEASE: ${{ inputs.pre_release }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
|
||||
|
||||
@@ -21,30 +21,52 @@ const env = {
|
||||
KILO_BUMP: process.env["KILO_BUMP"],
|
||||
KILO_VERSION: process.env["KILO_VERSION"],
|
||||
KILO_RELEASE: process.env["KILO_RELEASE"],
|
||||
KILO_PRE_RELEASE: process.env["KILO_PRE_RELEASE"],
|
||||
}
|
||||
// kilocode_change end
|
||||
const CHANNEL = await (async () => {
|
||||
if (env.KILO_CHANNEL) return env.KILO_CHANNEL // kilocode_change
|
||||
// kilocode_change start - publish to "rc" channel for pre-releases
|
||||
if (env.KILO_PRE_RELEASE === "true") return "rc"
|
||||
// kilocode_change end
|
||||
if (env.KILO_BUMP) return "latest" // kilocode_change
|
||||
if (env.KILO_VERSION && !env.KILO_VERSION.startsWith("0.0.0-")) return "latest" // kilocode_change
|
||||
return await $`git branch --show-current`.text().then((x) => x.trim())
|
||||
})()
|
||||
const IS_PREVIEW = CHANNEL !== "latest"
|
||||
|
||||
// kilocode_change start - shared helpers for version computation
|
||||
async function fetchLatest() {
|
||||
const data: any = await fetch("https://registry.npmjs.org/@kilocode/cli/latest").then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
return res.json()
|
||||
})
|
||||
return data.version as string
|
||||
}
|
||||
|
||||
function bumpVersion(current: string, type: string) {
|
||||
const [major, minor, patch] = current.split(".").map((x: string) => Number(x) || 0)
|
||||
if (type === "major") return `${major + 1}.0.0`
|
||||
if (type === "minor") return `${major}.${minor + 1}.0`
|
||||
return `${major}.${minor}.${patch + 1}`
|
||||
}
|
||||
// kilocode_change end
|
||||
|
||||
const VERSION = await (async () => {
|
||||
if (env.KILO_VERSION) return env.KILO_VERSION // kilocode_change
|
||||
if (IS_PREVIEW) return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
|
||||
const version = await fetch("https://registry.npmjs.org/@kilocode/cli/latest") // kilocode_change
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error(res.statusText)
|
||||
return res.json()
|
||||
})
|
||||
.then((data: any) => data.version)
|
||||
const [major, minor, patch] = version.split(".").map((x: string) => Number(x) || 0)
|
||||
const t = env.KILO_BUMP?.toLowerCase() // kilocode_change
|
||||
if (t === "major") return `${major + 1}.0.0`
|
||||
if (t === "minor") return `${major}.${minor + 1}.0`
|
||||
return `${major}.${minor}.${patch + 1}`
|
||||
if (IS_PREVIEW) {
|
||||
// kilocode_change start - compute semver prerelease for rc channel
|
||||
if (env.KILO_BUMP && env.KILO_PRE_RELEASE === "true") {
|
||||
const current = await fetchLatest()
|
||||
const base = bumpVersion(current, env.KILO_BUMP.toLowerCase())
|
||||
const stamp = new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")
|
||||
return `${base}-rc.${stamp}`
|
||||
}
|
||||
// kilocode_change end
|
||||
return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
|
||||
}
|
||||
const version = await fetchLatest() // kilocode_change
|
||||
return bumpVersion(version, env.KILO_BUMP?.toLowerCase() ?? "patch") // kilocode_change
|
||||
})()
|
||||
|
||||
// kilocode_change start
|
||||
|
||||
+4
-1
@@ -72,7 +72,10 @@ if (Script.release) {
|
||||
// await import(`../packages/desktop-electron/scripts/finalize-latest-yml.ts`)
|
||||
// kilocode_change end
|
||||
|
||||
await $`gh release edit v${Script.version} --draft=false --repo ${process.env.GH_REPO}`
|
||||
// kilocode_change start - mark prerelease GitHub releases accordingly
|
||||
const flags = Script.preview ? ["--draft=false", "--prerelease"] : ["--draft=false"]
|
||||
await $`gh release edit v${Script.version} ${flags} --repo ${process.env.GH_REPO}`
|
||||
// kilocode_change end
|
||||
}
|
||||
|
||||
console.log("\n=== cli ===\n")
|
||||
|
||||
+4
-2
@@ -17,12 +17,14 @@ if (!Script.preview) {
|
||||
const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
|
||||
output.push(`release=${release.databaseId}`)
|
||||
output.push(`tag=${release.tagName}`)
|
||||
} else if (Script.channel === "beta") {
|
||||
await $`gh release create v${Script.version} -d --title "v${Script.version}" --repo ${process.env.GH_REPO}`
|
||||
// kilocode_change start - handle both beta and rc preview channels
|
||||
} else if (Script.channel === "beta" || Script.channel === "rc") {
|
||||
await $`gh release create v${Script.version} -d --prerelease --title "v${Script.version}" --repo ${process.env.GH_REPO}`
|
||||
const release =
|
||||
await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
|
||||
output.push(`release=${release.databaseId}`)
|
||||
output.push(`tag=${release.tagName}`)
|
||||
// kilocode_change end
|
||||
}
|
||||
|
||||
output.push(`repo=${process.env.GH_REPO}`)
|
||||
|
||||
Reference in New Issue
Block a user