LibreChat/.github/workflows/data-provider.yml
Danny Avila c9b7ab4726
🔁 ci: Skip the data-provider publish when its version is already on npm (#17639)
Pushes to main that touch packages/data-provider/package.json without bumping the version failed with "You cannot publish over the previously published versions". Check whether the exact version already exists on the registry and skip packing and publishing when it does, as the client workflow does.
2026-10-29 22:12:24 +01:00

83 lines
2.5 KiB
YAML

name: Publish `librechat-data-provider` to NPM
on:
push:
branches:
- main
paths:
- 'packages/data-provider/package.json'
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual trigger'
required: false
default: 'Manual publish requested'
permissions:
contents: read
jobs:
pack:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: '24.22.1'
- run: cd packages/data-provider && npm ci
- run: cd packages/data-provider && npm run build
- name: Check version change
id: check
working-directory: packages/data-provider
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if npm view "librechat-data-provider@$PACKAGE_VERSION" version 2>/dev/null | grep -q .; then
echo "Version $PACKAGE_VERSION is already published, skipping publish"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Version $PACKAGE_VERSION is unpublished, proceeding with publish"
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Pack package
if: steps.check.outputs.skip != 'true'
run: |
mkdir -p npm-package
cd packages/data-provider
npm pack --pack-destination "$GITHUB_WORKSPACE/npm-package"
- name: Upload package
if: steps.check.outputs.skip != 'true'
uses: actions/upload-artifact@v6
with:
name: librechat-data-provider-package
path: npm-package/*.tgz
if-no-files-found: error
retention-days: 2
publish-npm:
needs: pack
if: github.ref == 'refs/heads/main' && needs.pack.outputs.skip != 'true'
runs-on: ubuntu-latest
environment: publish # Must match npm trusted publisher config
permissions:
contents: read
id-token: write # Required for OIDC trusted publishing
steps:
- uses: actions/setup-node@v5
with:
node-version: '24.22.1'
registry-url: 'https://registry.npmjs.org'
- name: Install npm with OIDC support
run: npm install -g npm@11.14.1 --ignore-scripts
- name: Download package
uses: actions/download-artifact@v7
with:
name: librechat-data-provider-package
path: npm-package
- name: Publish package
working-directory: npm-package
run: npm publish *.tgz --provenance