Skip to content

Publish to NPM

Publish to NPM #2

Workflow file for this run

name: Publish to NPM
permissions:
contents: write
id-token: write
packages: write
on:
workflow_dispatch:
inputs:
version:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
default: patch
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24.x
- name: Log NPM version
run: npm -v
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
run: npm ci
- name: Run format check
run: npm run format:check
- name: Run linter
run: npm run lint
- name: Build application
run: npm run build
- name: Run tests
run: npm test
- name: Bump version
run: npm version ${{ inputs.version }} -m "🔖 @huggingface/tokenizers@%s"
- name: Get new version
id: package-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Push changes
run: |
git push
git push --tags
- name: Publish to NPM
run: npm publish