Publish Node SDK to npm #13
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: Publish Node SDK to npm | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| registry-url: 'https://registry.npmjs.org' | |
| node-version: '20' | |
| - name: Enable corepack | |
| run: corepack enable pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run Build | |
| run: pnpm build | |
| - name: Publish to npm | |
| run: pnpm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Get version from package.json | |
| id: package-version | |
| run: | | |
| VERSION=$(jq -r '.version' package.json) | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: Could not extract version from package.json" | |
| exit 1 | |
| fi | |
| echo "current-version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.package-version.outputs.current-version }} | |
| name: v${{ steps.package-version.outputs.current-version }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true |