TypeScript SDK Integration Build & Publish auto from thiagohora/OPIK-6901/prune-trace-delete-partitions by @thiagohora #1857
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: TypeScript SDK Integration Build & Publish | |
| run-name: "TypeScript SDK Integration Build & Publish ${{ github.event.inputs.version || inputs.version || 'auto' }} from ${{github.ref_name}} by @${{ github.actor }}" | |
| on: | |
| push: | |
| paths: | |
| - "sdks/typescript/src/opik/integrations/**" | |
| - ".github/workflows/typescript_sdk_integration_publish.yml" | |
| pull_request: | |
| paths: | |
| - "sdks/typescript/src/opik/integrations/**" | |
| - ".github/workflows/typescript_sdk_integration_publish.yml" | |
| # NOTE: `is_release` is intentionally NOT a workflow_dispatch input. See | |
| # typescript_sdk_publish.yml — npm validates the *entry-point* workflow filename | |
| # and a package can have only one trusted publisher, so | |
| # `release-wrapper-release-n-deploy.yml` is the registered publisher for these | |
| # packages. A direct dispatch of this workflow builds and tests only; to publish, | |
| # go through the release wrapper. | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| type: string | |
| required: true | |
| description: Version | |
| default: "" | |
| skip_commit_push: | |
| type: boolean | |
| required: false | |
| description: Skip commit and push | |
| default: false | |
| workflow_call: | |
| inputs: | |
| version: | |
| type: string | |
| required: true | |
| description: Version | |
| is_release: | |
| type: boolean | |
| required: false | |
| default: false | |
| skip_commit_push: | |
| type: boolean | |
| required: false | |
| default: false | |
| concurrency: | |
| group: ts-sdk-integration-publish-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| # See typescript_sdk_publish.yml — `id-token: write` is required for npm | |
| # trusted publishing (OIDC) on both this workflow and its caller. | |
| contents: write | |
| id-token: write | |
| strategy: | |
| matrix: | |
| integration: | |
| - opik-openai | |
| - opik-gemini | |
| - opik-langchain | |
| - opik-vercel | |
| - opik-otel | |
| env: | |
| IS_RELEASE: ${{ inputs.is_release }} | |
| INTEGRATION: ${{ matrix.integration }} | |
| WORKING_DIR: sdks/typescript/src/opik/integrations/${{ matrix.integration }} | |
| defaults: | |
| run: | |
| working-directory: ${{ env.WORKING_DIR }} | |
| steps: | |
| - name: Checkout | |
| # For releases, check out the tag for the version we're publishing — not | |
| # `github.ref` (which is the dispatch ref and may have moved past the tag). | |
| # Convention: tag name == version string. Locks the build to the commit | |
| # the tag points to, so the published tarball is reproducible from the | |
| # version label. Non-release runs (build-only PR / push triggers) keep | |
| # the dispatch ref because there's no tag to pin to. | |
| # | |
| # NOTE: This is duplicated with typescript_sdk_publish.yml. We tried | |
| # extracting into a local composite action but a local composite cannot | |
| # be a workflow's first step — the repo isn't checked out yet, so the | |
| # composite's action.yml is not on the runner's filesystem. Keep the | |
| # checkout inline. | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ env.IS_RELEASE == 'true' && format('refs/tags/{0}', inputs.version) || github.ref }} | |
| fetch-depth: 0 | |
| token: ${{ secrets.GH_PAT_TO_ACCESS_GITHUB_API || github.token }} | |
| - name: Verify integration exists | |
| run: | | |
| if [ ! -d "${{ github.workspace }}/${{ env.WORKING_DIR }}" ]; then | |
| echo "Error: Integration '${{ env.INTEGRATION }}' not found at path: ${{ env.WORKING_DIR }}" | |
| exit 1 | |
| fi | |
| echo "Integration '${{ env.INTEGRATION }}' found" | |
| - name: Build and Publish TypeScript SDK Integration | |
| id: build_publish | |
| uses: ./.github/actions/typescript-sdk-build-and-publish | |
| with: | |
| working_directory: ${{ env.WORKING_DIR }} | |
| version: ${{ inputs.version || '' }} | |
| is_release: ${{ env.IS_RELEASE }} | |
| package_name: ${{ env.INTEGRATION }} | |
| npm_access: "public" | |
| enable_cache: "true" | |
| cache_dependency_path: ${{ env.WORKING_DIR }}/package-lock.json | |
| test_package_installation: "true" | |
| github_token: ${{ secrets.GH_PAT_TO_ACCESS_GITHUB_API || github.token }} | |
| skip_commit_push: ${{ inputs.skip_commit_push }} | |
| - name: Summary | |
| run: | | |
| exec >> "$GITHUB_STEP_SUMMARY" | |
| echo "## ${{ env.INTEGRATION }} Build" | |
| echo "" | |
| echo "**Version:** ${{ steps.build_publish.outputs.version }}" | |
| echo "**Event:** ${{ github.event_name }}" | |
| echo "**Is Release:** ${{ env.IS_RELEASE }}" | |
| if [ "${{ env.IS_RELEASE }}" = "true" ]; then | |
| echo "**Published:** ✅ Published to NPM" | |
| echo "**Package:** 📦 ${{ steps.build_publish.outputs.package_name }}@${{ steps.build_publish.outputs.version }}" | |
| echo "**NPM:** 🔗 https://www.npmjs.com/package/${{ steps.build_publish.outputs.package_name }}/v/${{ steps.build_publish.outputs.version }}" | |
| echo "" | |
| echo "**Install with:**" | |
| echo "\`\`\`bash" | |
| echo "npm install ${{ steps.build_publish.outputs.package_name }}@${{ steps.build_publish.outputs.version }}" | |
| echo "\`\`\`" | |
| else | |
| echo "**Status:** ⏭️ Build and tests only" | |
| fi |