Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 262 additions & 0 deletions .github/workflows/cli-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
name: Publish CLI
on:
pull_request:
types: [closed]
workflow_dispatch:

env:
GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
NODE_VERSION: 20.19.2
PNPM_VERSION: 10.8.1
DOCKER_IMAGE_NAME: kiloai/cli
DOCKER_PLATFORMS: linux/amd64,linux/arm64

jobs:
check-version:
runs-on: ubuntu-latest
if: >
( github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main' &&
contains(github.event.pull_request.title, 'Changeset version bump') ) ||
github.event_name == 'workflow_dispatch'
outputs:
version: ${{ steps.check.outputs.version }}
publish: ${{ steps.check.outputs.publish }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Check Published Version
id: check
working-directory: cli
run: |
version=$(node -p "require('./package.json').version")
published_version=$(npm view @kilocode/cli version 2>/dev/null || echo "0.0.0")
if npx semver "$version" -r "> $published_version"; then
echo "publish=true" >> $GITHUB_OUTPUT
else
echo "publish=false" >> $GITHUB_OUTPUT
fi
echo "version=$version" >> $GITHUB_OUTPUT

build-and-test:
needs: check-version
if: needs.check-version.outputs.publish == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
- name: Turbo cache setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Install dependencies
run: pnpm install
- name: Create .env file
working-directory: cli
run: echo "KILOCODE_POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> .env
- name: Build CLI
shell: bash
run: pnpm run cli:bundle
- name: Run integration tests
shell: bash
run: pnpm --filter @kilocode/cli test:integration
env:
CI: true
KILOCODE_TOKEN: ${{ secrets.KILOCODE_INTEGRATION_TOKEN }}
KILOCODE_ORGANIZATION_ID: ${{ secrets.KILOCODE_INTEGRATION_ORGANIZATION_ID }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: cli-build
path: cli/dist
retention-days: 1

publish-npm:
needs: [check-version, build-and-test]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: cli-build
path: cli/dist
- name: Publish to NPM
working-directory: cli/dist
run: npm publish --access public

pack-npm:
needs: [check-version, build-and-test]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: cli-build
path: cli/dist
- name: Pack CLI
working-directory: cli/dist
run: npm pack
- name: Upload Packaged CLI
uses: actions/upload-artifact@v4
with:
name: cli-packaged
path: cli/dist/*.tgz
retention-days: 1

publish-docker-debian:
needs: [check-version, build-and-test, pack-npm]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Download Packaged CLI
uses: actions/download-artifact@v4
with:
name: cli-packaged
path: cli/dist
- name: Build and push Debian image
uses: docker/build-push-action@v5
with:
context: ./cli
file: ./cli/Dockerfile
target: debian
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
tags: |
${{ env.DOCKER_IMAGE_NAME }}:${{ needs.check-version.outputs.version }}
${{ env.DOCKER_IMAGE_NAME }}:latest
${{ env.DOCKER_IMAGE_NAME }}:${{ needs.check-version.outputs.version }}-debian
${{ env.DOCKER_IMAGE_NAME }}:latest-debian
build-args: |
VERSION=${{ needs.check-version.outputs.version }}
BUILD_DATE=${{ github.event.repository.updated_at }}
VCS_REF=${{ github.sha }}

publish-docker-alpine:
needs: [check-version, build-and-test, pack-npm]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Download Packaged CLI
uses: actions/download-artifact@v4
with:
name: cli-packaged
path: cli/dist
- name: Build and push Alpine image
uses: docker/build-push-action@v5
with:
context: ./cli
file: ./cli/Dockerfile
target: alpine
platforms: ${{ env.DOCKER_PLATFORMS }}
push: true
cache-from: type=gha,scope=alpine
cache-to: type=gha,mode=max,scope=alpine
tags: |
${{ env.DOCKER_IMAGE_NAME }}:${{ needs.check-version.outputs.version }}-alpine
${{ env.DOCKER_IMAGE_NAME }}:latest-alpine
build-args: |
VERSION=${{ needs.check-version.outputs.version }}
BUILD_DATE=${{ github.event.repository.updated_at }}
VCS_REF=${{ github.sha }}

create-release:
needs: [check-version, pack-npm, publish-npm, publish-docker-debian, publish-docker-alpine]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: cli-packaged
path: cli/dist
- name: Create and Push Git Tag
run: |
version=${{ needs.check-version.outputs.version }}
if git ls-remote --tags origin | grep -q "refs/tags/cli-v${version}$"; then
echo "Tag cli-v${version} already exists remotely, skipping tag creation"
else
git tag -a "cli-v${version}" -m "Release CLI - cli-v${version}"
git push origin "cli-v${version}" --no-verify
echo "Successfully created and pushed git tag cli-v${version}"
fi
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=${{ needs.check-version.outputs.version }}
if gh release view "cli-v${version}" >/dev/null 2>&1; then
exit 0
fi
changelog_content=$(sed -E -n "/^## \\[?v?${version}\\]?/,/^## /p" cli/CHANGELOG.md | sed '$d')
gh release create "cli-v${version}" \
--title "Release CLI - v${version}" \
--notes "$changelog_content" \
--target main \
cli/dist/kilocode-cli-${version}.tgz
echo "Successfully created CLI GitHub Release v${version}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ qdrant_storage/
# allow multiple local clones with different workspaces with different colors
# to make it easier to work on features in parallel
*.code-workspace

# Act Secret Files
.secrets
66 changes: 0 additions & 66 deletions cli/.dockerignore

This file was deleted.

6 changes: 5 additions & 1 deletion cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
dist
node_modules
node_modules

# Integration test temp files
integration-tests/**/*.log
**/kilocode-cli-tests/
Loading