mirror of
https://github.com/firecrawl/cli.git
synced 2026-09-14 17:30:55 +08:00
73 lines
2.1 KiB
YAML
73 lines
2.1 KiB
YAML
name: Publish to npm
|
|
|
|
on:
|
|
release:
|
|
types: [created]
|
|
workflow_dispatch:
|
|
push:
|
|
paths:
|
|
- 'package.json'
|
|
- .github/workflows/publish.yml
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: '24'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10.12.1
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: pnpm run build
|
|
|
|
- name: Check version and determine publish tag
|
|
id: check-version
|
|
run: |
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
|
|
# Check if version contains beta
|
|
if [[ "$VERSION" == *"-alexandria"* ]]; then
|
|
echo "tag=alexandria" >> $GITHUB_OUTPUT
|
|
echo "Version $VERSION will publish with the alexandria tag"
|
|
elif [[ "$VERSION" == *"beta"* ]]; then
|
|
echo "tag=beta" >> $GITHUB_OUTPUT
|
|
echo "Version $VERSION contains beta, will publish with beta tag"
|
|
else
|
|
echo "tag=latest" >> $GITHUB_OUTPUT
|
|
echo "Version $VERSION is stable, will publish with latest tag"
|
|
fi
|
|
|
|
if npm view ${PACKAGE_NAME}@${VERSION} version > /dev/null 2>&1; then
|
|
echo "exists=true" >> $GITHUB_OUTPUT
|
|
echo "Version $VERSION already exists on npm, skipping publish"
|
|
else
|
|
echo "exists=false" >> $GITHUB_OUTPUT
|
|
echo "Version $VERSION is new, will publish"
|
|
fi
|
|
|
|
- name: Publish to npm
|
|
if: steps.check-version.outputs.exists == 'false'
|
|
run: npm publish --provenance --access public --tag ${{ steps.check-version.outputs.tag }}
|
|
continue-on-error: false
|