| name: Publish @mem0/cli 📦 to npm | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| build-n-publish: | |
| name: Build and publish @mem0/cli 📦 to npm | |
| if: startsWith(github.event.release.tag_name, 'cli-node-v') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| defaults: | |
| run: | |
| working-directory: cli/node | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'pnpm' | |
| cache-dependency-path: cli/node/pnpm-lock.yaml | |
| - name: Upgrade npm for OIDC trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm run build | |
| - name: Publish to npm | |
| run: | | |
| if [ "${{ github.event.release.prerelease }}" = "true" ]; then | |
| PREID=$(node -p "require('./package.json').version.split('-')[1].split('.')[0]") | |
| npm publish --provenance --access public --tag "$PREID" | |
| else | |
| npm publish --provenance --access public | |
| fi | |