TypeScript SDK Build & Publish auto from main by @CometActions #1792
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 Build & Publish | |
| run-name: "TypeScript SDK Build & Publish ${{ github.event.inputs.version || inputs.version || 'auto' }} from ${{github.ref_name}} by @${{ github.actor }}" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "sdks/typescript/**" | |
| - ".github/workflows/typescript_sdk_publish.yml" | |
| pull_request: | |
| paths: | |
| - "sdks/typescript/**" | |
| - ".github/workflows/typescript_sdk_publish.yml" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| type: string | |
| required: true | |
| description: Version | |
| default: "" | |
| is_release: | |
| type: boolean | |
| required: false | |
| description: Whether this is a release (publishes to NPM) | |
| default: false | |
| 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-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: 5 | |
| env: | |
| IS_RELEASE: ${{ inputs.is_release }} | |
| defaults: | |
| run: | |
| working-directory: sdks/typescript | |
| 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: We extract this into a local composite action originally, 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. See the closed comment thread on | |
| # PR #7124 for the failure mode. | |
| 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: Build and Publish TypeScript SDK | |
| id: build_publish | |
| uses: ./.github/actions/typescript-sdk-build-and-publish | |
| with: | |
| working_directory: sdks/typescript | |
| version: ${{ inputs.version || '' }} | |
| is_release: ${{ env.IS_RELEASE }} | |
| package_name: "TypeScript SDK" | |
| npm_token: ${{ secrets.NPM_TOKEN }} | |
| 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 "## TypeScript SDK 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" | |
| else | |
| echo " ⏭️ Build only " | |
| fi |