|
| 1 | +# Release process |
| 2 | + |
| 3 | +## Version |
| 4 | + |
| 5 | +Unlike some other tree-sitter grammars, the R grammar's release version is not tied to the tree-sitter version. Instead, we just use standard semantic versioning. We released 1.0.0 when we merged the longstanding `next` branch into `main`, and then we froze `main-old` for people to pin to if they are slow to update. |
| 6 | + |
| 7 | +## R package |
| 8 | + |
| 9 | +<https://cran.r-project.org/web/packages/treesitter.r/index.html> |
| 10 | + |
| 11 | +Davis is the maintainer. |
| 12 | + |
| 13 | +The {treesitter.r} package is relatively simple. It just provides `language()` as an external pointer into the C level tree-sitter-r grammar struct. |
| 14 | + |
| 15 | +- Decide if you also need to release [{treesitter}](https://github.com/DavisVaughan/r-tree-sitter). |
| 16 | +- Ensure you `devtools::load_all()` twice to ensure that `bootstrap.R` runs and pulls updated files into `src/` and updates any ABI changes. |
| 17 | +- Run `devtools::check()` to ensure tests are still passing. |
| 18 | +- Run `devtools::release()` to do a standard R package release if all looks good. |
| 19 | + - Use the same version as the Rust crate and the npm package. |
| 20 | + |
| 21 | +If in {treesitter} you have to deal with a bump in the minimal ABI supported by tree-sitter, then you'll definitely have to do a release of the {treesitter.r} package as well. There are tools in `abi.R` that will need to be updated with the ABI that tree-sitter-r's parser was generated with, but `bootstrap.R` will do this for you. The worst case would be if tree-sitter bumped their ABI version to X and also raised the *minimal* ABI version to X as well, due to some serious breaking change. If that happens, then you'll have to release both {treesitter} and {treesitter.r} as close together as possible, because {treesitter} will complain that it isn't compatible with the grammar from {treesitter.r}. |
| 22 | + |
| 23 | +It's worth noting that {treesitter.r} does not actually Import {treesitter}, it just Suggests it. This is generally preferred in the tree-sitter ecosystem. {treesitter} just knows how to consume the external pointer that {treesitter.r} creates. |
| 24 | + |
| 25 | +## Rust crate |
| 26 | + |
| 27 | +<https://docs.rs/tree-sitter-r/latest/tree_sitter_r/> |
| 28 | + |
| 29 | +Davis is the main owner of the crate, but Kevin also has publish rights. |
| 30 | + |
| 31 | +- Use `tree-sitter init --update` to update language specific files, in particular `Cargo.toml`, `bindings/rust/lib.rs` and `bindings/rust/build.rs`. |
| 32 | + |
| 33 | +- Note that tree-sitter-r only depends on `tree-sitter-language`, not the `tree-sitter` crate. |
| 34 | + |
| 35 | +- The `build.rs` script will compile in `parser.c` and `scanner.c` on a crate build. This gives `lib.rs` access to `fn tree_sitter_r() -> *const ()`, which then becomes the `LanguageFn` defined in `tree-sitter-language`. |
| 36 | + |
| 37 | +- Don't forget to update the version in `Cargo.toml` to the same version used in the R package. |
| 38 | + |
| 39 | +- `cargo publish --dry-run` will do a dry run before submitting |
| 40 | + |
| 41 | +- `cargo publish` to actually release |
| 42 | + |
| 43 | +## Npm package |
| 44 | + |
| 45 | +Davis is the maintainer of the package. |
| 46 | + |
| 47 | +We use [nvm](https://github.com/nvm-sh/nvm) for npm version management. The npm version is specified in `.nvmrc`. |
| 48 | + |
| 49 | +- Use `tree-sitter init --update` to update language specific files, in particular `package.json`, `bindings/node/*`. |
| 50 | + |
| 51 | +- For the `peerDependencies` of `tree-sitter`, we typically use the same version that tree-sitter-rust's npm bindings use, if it seems like it makes sense. |
| 52 | + |
| 53 | +- To test the bindings in a basic way |
| 54 | + |
| 55 | + ``` |
| 56 | + # To respect .nvmrc |
| 57 | + nvm use |
| 58 | + npm install |
| 59 | + # If tree-sitter doesn't get installed |
| 60 | + # npm install tree-sitter --save-dev |
| 61 | + npm test |
| 62 | + ``` |
| 63 | +
|
| 64 | +- If you need to reset the node package cache, delete `node_modules/` |
| 65 | +
|
| 66 | +- `npm publish --dry-run` will do a dry run |
| 67 | +
|
| 68 | +- `npm publish` will actually publish |
| 69 | +
|
| 70 | +You may need to login to npm through the command line first, use `npm login` for that. |
| 71 | +
|
| 72 | +We publish as an [unscoped public package](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages) because that seems to be what other tree-sitter grammars do as well. |
0 commit comments