Skip to content

Format codebase

Format codebase #57

name: Node SDK
on:
push:
paths:
- "sdks/node/**"
jobs:
build:
name: 📦 Build distribution
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
defaults:
run:
working-directory: ./sdks/node
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Node
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 9
run_install: false
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Store the distribution packages
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: redactive-node-sdk
path: ./sdks/node/dist/
publish:
name: 🚚 Publish Node SDK to NPM
if: startsWith(github.ref, 'refs/tags/') # only publish to NPM on tag pushes
needs: build
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
defaults:
run:
working-directory: ./sdks/node
steps:
# This needs to go first because checkout will overwrite the dist folder
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Download all the dists
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
name: redactive-node-sdk
path: ./sdks/node/dist/
- name: Set up Node
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- name: Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 9
run_install: false
- name: Detect package version tag # Set to beta if any tag is in version string
id: version_tag
run: |
echo "tag=$(if [[ ${GITHUB_REF#refs/*/} =~ ^v[0-9.]+$ ]]; then echo 'latest' ; else echo 'beta'; fi)" >> $GITHUB_OUTPUT
- name: Publish Node SDK to NPM
shell: bash
run: pnpm version ${GITHUB_REF#refs/*/} && pnpm publish --access public --no-git-checks --tag ${{steps.version_tag.outputs.tag}}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}