Improve agent manager telemetry #302
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: 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 | |
| compression-level: 0 | |
| 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 }} | |
| - name: Update npm | |
| run: npm install -g npm@latest | |
| - name: Download Build Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cli-packaged | |
| path: cli/dist | |
| - name: Publish to NPM | |
| working-directory: cli/dist | |
| run: | | |
| version=${{ needs.check-version.outputs.version }} | |
| npm publish --access public --provenance kilocode-cli-${version}.tgz | |
| publish-docker-debian: | |
| needs: [check-version, build-and-test] | |
| 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] | |
| 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, 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: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - 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}" |