| Allen George | f9f037b | 2018-12-27 13:56:21 -0500 | [diff] [blame] | 1 | # Publishing the thrift crate |
| 2 | |
| 3 | Publishing the Rust thrift crate is straightforward, and involves two major steps: |
| 4 | |
| 5 | 1. Setting up your [crates.io](https://www.crates.io) account _(one-time)_ |
| 6 | |
| 7 | 2. Packaging/publishing the Rust thrift crate itself |
| 8 | |
| 9 | ## Set up your crates.io account (one-time) |
| 10 | |
| 11 | 1. Go to [crates.io](https://www.crates.io) and click the `Log In` button at the top right. |
| 12 | |
| 13 | Log in **as the Github user with write permissions to the thrift repo!** |
| 14 | |
| 15 | 2. Click your user icon button at the top right and select `Account Settings`. |
| 16 | |
| 17 | 3. Click `New Token` next to `API Access`. |
| 18 | |
| 19 | This generates a new API key that cargo uses to publish packages to crates.io. |
| 20 | Store this API key somewhere safe. If you will only use this Github account to |
| 21 | publish crates to crates.io you can follow the instructions to save the |
| 22 | generated key to `~/.cargo/credentials`. |
| 23 | |
| 24 | ## Package and Publish |
| 25 | |
| 26 | You can use the automated script or run the release steps manually. |
| 27 | |
| 28 | **Important**: `cargo` expects that version numbers follow the semantic versioning format. |
| 29 | This means that `THRIFT_RELEASE_VERSION` must have a major, minor and patch number, i.e., must |
| 30 | be in the form `#.##.##`. |
| 31 | |
| 32 | #### Automated |
| 33 | |
| 34 | Run `./release.sh [THRIFT_RELEASE_VERSION]`. |
| 35 | |
| 36 | _Requires you to have stored your credentials in `~/.cargo/credentials`._ |
| 37 | |
| 38 | #### Manual |
| 39 | |
| 40 | 1. Edit `Cargo.toml` and update the `version = 1.0` key to `version = [THRIFT_RELEASE_VERSION]` |
| 41 | |
| 42 | 2. `git add Cargo.toml` |
| 43 | |
| 44 | 3. `git commit -m "Update thrift crate version to [THRIFT_RELEASE_VERSION]" -m "Client: rs"` |
| 45 | |
| 46 | 4. `cargo login` |
| 47 | |
| 48 | _(not required if you have stored your credentials in `~/.cargo/credentials`)_ |
| 49 | |
| 50 | 5. `cargo clean` |
| 51 | |
| 52 | 6. `cargo package` |
| 53 | |
| 54 | This step fails if there are any uncommitted or ignored files. Do **not** use the `--allow-dirty` |
| 55 | flag! Instead, add the highlighted files as entries in the `Cargo.toml` `exclude` key. |
| 56 | |
| 57 | 7. `cargo publish` |