Skip to main content

Publishing Your Grammar

Once your parser is stable and well-tested, you can publish it to make it available to others.

Publishing Platforms

Publish your grammar to multiple registries to maximize discoverability:

GitHub

Host your source code and releases

crates.io

Rust package registry

npm

JavaScript package registry

PyPI

Python package index
Publishing to all platforms ensures your parser is accessible to users in different ecosystems.

Automated Publishing

Use Tree-sitter’s reusable workflows to automate the publishing process.

Setup GitHub Workflows

Create .github/workflows/publish.yml:
.github/workflows/publish.yml

Configure Secrets

Add repository secrets in GitHub Settings > Secrets and variables > Actions:
1

CARGO_TOKEN

Get from crates.io/me > API Tokens
2

NPM_TOKEN

Generate with npm token create or at npmjs.com
3

PYPI_TOKEN

The workflow automatically regenerates the parser and publishes to all configured registries when you push a version tag.

Release Process

Follow these steps to release a new version:
1

Bump version

This updates version numbers in:
  • package.json
  • Cargo.toml
  • pyproject.toml
2

Commit changes

Ensure your working directory is clean.
3

Create tag

The tag name must start with v to trigger the workflow.
4

Push to GitHub

This triggers the automated publishing workflow.
5

Verify workflow

Check GitHub Actions to ensure the workflow succeeds.

Semantic Versioning

Follow Semantic Versioning for predictable updates:

Version Format

When to Increment

MAJOR

Incompatible grammar changes:
  • Node type renames
  • Structural changes
  • Removed nodes

MINOR

New features:
  • New node types
  • New patterns
  • Added fields

PATCH

Bug fixes:
  • Parse errors fixed
  • No structural changes
  • Performance improvements

Pre-1.0 Versions

For 0.y.z versions (pre-release), be more conservative:
Treat minor version changes as major changes, and patch changes as minor changes to maintain stability for early users.
Example:
  • 0.1.00.2.0: Breaking grammar changes
  • 0.1.00.1.1: New features
  • 0.1.00.1.0-patch.1: Bug fixes only

Manual Publishing

If you prefer manual control, publish to each registry separately:

Cargo (Rust)

npm (JavaScript)

PyPI (Python)

Pre-Release Checklist

Before publishing, ensure:
  • README explains how to use the parser
  • Examples show common use cases
  • Grammar rules are documented
  • Field names are described
  • All rules have test coverage
  • Edge cases are tested
  • Tests pass on all platforms
  • CI/CD is green
  • Version number is accurate
  • License is specified
  • Author information is filled in
  • Repository URL is set
  • No compiler warnings
  • External scanner is well-tested
  • Performance is acceptable
  • Memory is properly managed

Repository Structure

A well-organized repository includes:

README Template

Provide a clear README:
README.md

Cargo

PyPI

Usage

Node.js

Rust

Python

Development

Contributing

Contributions are welcome! Please:
  1. Fork the repository
  2. Create a feature branch
  3. Add tests for your changes
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Regular Releases

Release updates regularly to:
  • Fix reported bugs
  • Add requested features
  • Improve performance
  • Update documentation

Example: Python Grammar

The tree-sitter-python repository is an excellent example:
  • Comprehensive tests
  • Automated publishing workflow
  • Good documentation
  • Active maintenance
  • Multiple platform support

Next Steps

Congratulations on publishing your parser! Consider:
  • Adding query files for syntax highlighting
  • Creating editor integrations (Neovim, Emacs, VSCode)
  • Writing documentation about interesting grammar patterns
  • Contributing to other Tree-sitter projects
Join the Tree-sitter discussion forum to connect with other parser authors and get help.