From 7c76790ad30ef182a510b2ac8264d357d98b6ed1 Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Tue, 12 May 2026 09:17:49 +0300 Subject: [PATCH] ci(publish-sdk): trigger workflow on release - add release event trigger to automate publishing - update versioning logic to support release tags - conditionally skip git tagging when triggered by release --- .github/workflows/publish-sdk.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-sdk.yml b/.github/workflows/publish-sdk.yml index 01b03f9..7defa8b 100644 --- a/.github/workflows/publish-sdk.yml +++ b/.github/workflows/publish-sdk.yml @@ -1,6 +1,8 @@ name: Publish SDK to npm on: + release: + types: [published] workflow_dispatch: inputs: version: @@ -41,8 +43,14 @@ jobs: run: pnpm install --frozen-lockfile - name: Bump version - if: inputs.version != '' - run: npm version ${{ inputs.version }} --no-git-tag-version + run: | + if [ "${{ github.event_name }}" = "release" ]; then + VERSION="${{ github.event.release.tag_name }}" + VERSION="${VERSION#v}" + npm version "$VERSION" --no-git-tag-version + elif [ -n "${{ inputs.version }}" ]; then + npm version ${{ inputs.version }} --no-git-tag-version + fi - name: Typecheck run: pnpm typecheck @@ -60,18 +68,18 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Publish - if: inputs.dry-run == false + if: github.event_name == 'release' || inputs.dry-run != true run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Get published version - if: inputs.dry-run == false + if: github.event_name == 'release' || inputs.dry-run != true id: version run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT - name: Create git tag - if: inputs.dry-run == false + if: github.event_name != 'release' && inputs.dry-run != true working-directory: . run: | git config user.name "github-actions[bot]"