-
Notifications
You must be signed in to change notification settings - Fork 1.4k
CLI - Publish Workflow #4064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+928
−142
Merged
CLI - Publish Workflow #4064
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b93306d
CLI: Add integration spec framework
RSO 737aeda
Properly override CONFIG_DIR for CLI
RSO 45f905a
Run the full test
RSO 0bf5900
Set up GitHub Action
RSO 14446a5
Add required .env file
RSO 2309e93
Add .env file in correct working directory
RSO 6013b5c
refactor: to use KILO_EPHEMERAL_MODE and direct config env vars
catrielmuller f5b9cac
refactor: update pnpm lock
catrielmuller 7fe0b15
refactor: test with org id
catrielmuller 287b744
refactor: add act to flake
catrielmuller 3535bc3
refactor: fix CI env variable on integration test
catrielmuller b1c7024
refactor: test integration on gha
catrielmuller dfcec12
feat: publish on NPM / Git Tag / Release Page
catrielmuller c844393
refactor: update docker build process
catrielmuller 031bb9b
feat: Docker & NPM & Git Tag & Release Page Deploy
catrielmuller 6bf9c99
refactor: remove test file
catrielmuller e04c73e
refactor: add kilocode_change
catrielmuller 184382a
refactor: add image url
catrielmuller 17e12ec
Merge branch 'main' into catrielmuller/cli-publish-npm
catrielmuller a624beb
refactor: fix test
catrielmuller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| 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 }} | ||
catrielmuller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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}" | ||
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
This file was deleted.
Oops, something went wrong.
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
| 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/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.