Publish to NPM #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |