diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee0ca31..5f21a4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,8 @@ name: CI on: - pull_request: - branches: [main] + push: + branches: [dev, main] concurrency: group: ci-${{ github.ref }} @@ -124,3 +124,51 @@ jobs: -f tests/e2e/docker-compose.yml \ -p litellm-client-e2e \ down -v --remove-orphans || true + + # ───────────────────── publish (push to main only) ─────────── + # Fires after every CI gate passes on a push to main. Skips silently + # if package.json version is already on npm — bump the version to + # ship a release. + publish: + runs-on: ubuntu-latest + needs: [lint, unit-tests, build, e2e] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + registry-url: https://registry.npmjs.org + + - name: Check if version is already published + id: version_check + run: | + PKG_VERSION=$(node -p "require('./package.json').version") + PUBLISHED=$(npm view litellm-client version 2>/dev/null || echo "") + echo "pkg_version=$PKG_VERSION" >> "$GITHUB_OUTPUT" + echo "published=$PUBLISHED" >> "$GITHUB_OUTPUT" + if [ "$PKG_VERSION" = "$PUBLISHED" ]; then + echo "skip=true" >> "$GITHUB_OUTPUT" + echo "::notice title=Publish skipped::version $PKG_VERSION already on npm" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + fi + + - run: npm ci + if: steps.version_check.outputs.skip == 'false' + + - run: npm run build + if: steps.version_check.outputs.skip == 'false' + + # Authenticates to npm via OIDC (Trusted Publishing). No NPM_TOKEN + # required — the `id-token: write` permission above + a Trusted + # Publisher configured at npmjs.com/package/litellm-client/access + # for this repo + workflow is what authorizes the publish. + - name: Publish to npm + if: steps.version_check.outputs.skip == 'false' + run: npm publish --provenance --access public diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index c2baf4b..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish to npm - -on: - release: - types: [published] - -permissions: - contents: read - id-token: write - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: 24 - cache: npm - registry-url: https://registry.npmjs.org - - - run: npm ci - - # Type-check - - run: npx tsc --noEmit - - # Unit tests - - run: npm run test:unit - - # Build - - run: npm run build - - # Publish with provenance - - run: npm publish --provenance --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 4d2b387..4d937ab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # litellm-client [![CI](https://github.com/visgotti/litellm-client/actions/workflows/ci.yml/badge.svg)](https://github.com/visgotti/litellm-client/actions/workflows/ci.yml) -[![Codecov](https://codecov.io/gh/visgotti/litellm-client/branch/main/graph/badge.svg)](https://codecov.io/gh/visgotti/litellm-client) +[![codecov](https://codecov.io/gh/visgotti/litellm-client/graph/badge.svg?token=U7KS3N0NQ7)](https://codecov.io/gh/visgotti/litellm-client) [![npm](https://img.shields.io/npm/v/litellm-client.svg)](https://www.npmjs.com/package/litellm-client) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) diff --git a/package.json b/package.json index dd7829e..710fa40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "litellm-client", - "version": "1.0.0", + "version": "1.0.1", "description": "Production-grade TypeScript client for the LiteLLM proxy server. Zero runtime dependencies, full surface coverage, streaming, retries, typed errors.", "main": "dist/index.js", "types": "dist/index.d.ts",