|
| 1 | +<!-- cspell:ignore codeowner --> |
| 2 | + |
| 3 | +# Rust Crate Deprecation Process |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This guide describes the step-by-step process for deprecating a Rust crate in the `azure-sdk-for-rust` repository. You likely need to read this if you are a crate maintainer and need to explain to your users that the crate should no longer be used. |
| 8 | + |
| 9 | +Note that a deprecated crate is a signal to users that they are strongly encouraged to stop using it and migrate to another crate. The crate is still available to install from crates.io and is not yanked, and we still have the ability to publish critical security fixes as necessary. |
| 10 | + |
| 11 | +The overall approach for Rust crates is: |
| 12 | + |
| 13 | +- Add deprecation attributes to public APIs in the code to provide compile-time warnings |
| 14 | +- Update the `README.md` file with a deprecation disclaimer |
| 15 | +- Update the `CHANGELOG.md` file to document the deprecation |
| 16 | +- Add deprecation metadata to `Cargo.toml` |
| 17 | +- Publish a new release to crates.io |
| 18 | +- Update the API reference documentation to show the deprecated status |
| 19 | +- Eventually yank the crate from crates.io if the service is fully retired |
| 20 | + |
| 21 | +## Pre-deprecation: Blog Post |
| 22 | + |
| 23 | +If applicable, consider adding a post to the [Azure Blog](https://devblogs.microsoft.com/azure-sdk/) stating that: |
| 24 | + |
| 25 | +- A new crate is available which replaces the old crate |
| 26 | +- The old crate is scheduled to be deprecated on a specific date |
| 27 | +- Guidance on adjusting code to use the new crate |
| 28 | + |
| 29 | +Reach out to the Rust Azure SDK PM if you have any questions about creating a blog post. |
| 30 | + |
| 31 | +## Step 1: Updates to the crate files |
| 32 | + |
| 33 | +Clone the `azure-sdk-for-rust` repository and update the following files of your crate. |
| 34 | + |
| 35 | +### README.md |
| 36 | + |
| 37 | +A disclaimer should be added indicating the end-of-life date (EOLDate) of the crate and directing to a replacement crate and migration guide as necessary. |
| 38 | + |
| 39 | +- The EOLDate should be in the format `MM-DD-YYYY`. |
| 40 | + - If there is no replacement crate, the crate EOLDate should be the service retirement date. |
| 41 | + - If there is a replacement crate, the EOLDate should be the same as the deprecation release date of the old crate in the `CHANGELOG.md`. |
| 42 | + - Service retirement dates MAY be listed in the [Azure Services Retirement Workbook](https://aka.ms/servicesretirementworkbook), where retiring feature says 'Entire service'. |
| 43 | +- The link to the replacement crate should be a crates.io link: `https://crates.io/crates/azure_new_crate`. |
| 44 | +- The link to the migration guide should be a link in the format `https://aka.ms/azsdk/rust/migrate/new-crate`. To create this aka.ms link, follow the "How to create aka.ms links" section [here](https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/233/Azure-SDK-AKA.ms-Links?anchor=how-to-create-aka.ms-links). |
| 45 | + - NOTE: You may decide to postpone or skip writing a migration guide based on download numbers (found on [crates.io](https://crates.io/), [lib.rs](https://lib.rs/), etc.) and internal knowledge of the usage of the crate. |
| 46 | + |
| 47 | +Replace ALL existing text with a disclaimer in the following format: |
| 48 | + |
| 49 | +#### If a replacement crate and migration guide exist |
| 50 | + |
| 51 | +```markdown |
| 52 | +# Microsoft Azure SDK for Rust |
| 53 | + |
| 54 | +> [!CAUTION] |
| 55 | +> This crate has been deprecated and will no longer be maintained after <EOLDate>. This crate will only receive security fixes until <EOLDate>. To receive updates on new features and non-security bug fixes, upgrade to the replacement crate, [azure_new_crate](https://crates.io/crates/azure_new_crate). Refer to the [migration guide](https://aka.ms/azsdk/rust/migrate/new-crate) for guidance on upgrading. |
| 56 | +``` |
| 57 | + |
| 58 | +#### If a migration guide is not provided |
| 59 | + |
| 60 | +```markdown |
| 61 | +# Microsoft Azure SDK for Rust |
| 62 | + |
| 63 | +> [!CAUTION] |
| 64 | +> This crate has been deprecated and will no longer be maintained after <EOLDate>. This crate will only receive security fixes until <EOLDate>. To receive updates on new features and non-security bug fixes, upgrade to the replacement crate, [azure_new_crate](https://crates.io/crates/azure_new_crate). |
| 65 | +``` |
| 66 | + |
| 67 | +#### If a replacement crate does not exist |
| 68 | + |
| 69 | +```markdown |
| 70 | +# Microsoft Azure SDK for Rust |
| 71 | + |
| 72 | +> [!CAUTION] |
| 73 | +> This crate has been deprecated and will no longer be maintained after <EOLDate>. This crate will only receive security fixes until <EOLDate>. |
| 74 | +``` |
| 75 | + |
| 76 | +#### If a new service has replaced the service, and existing customers should be directed to the new service's REST API docs/repo |
| 77 | + |
| 78 | +```markdown |
| 79 | +# Microsoft Azure SDK for Rust |
| 80 | + |
| 81 | +> [!CAUTION] |
| 82 | +> This crate has been deprecated and will no longer be maintained after <EOLDate>. This crate will only receive security fixes until <EOLDate>. Refer to the samples in the [My New Service repo](https://github.com/microsoft/my-new-service/tree/main) instead. |
| 83 | + |
| 84 | +For additional support, open a new issue in the [Issues](https://github.com/microsoft/my-new-service/issues) section of the My New Service repo. |
| 85 | +``` |
| 86 | + |
| 87 | +### CHANGELOG.md and Cargo.toml version |
| 88 | + |
| 89 | +- Update the version in the crate's `Cargo.toml` file to the next patch version if the crate has had a stable release, or the next pre-release version if the crate has only been in pre-release. For example: |
| 90 | + |
| 91 | + - If a stable version WAS NEVER RELEASED and the last released version was 1.0.0-beta.1, the new version should be 1.0.0-beta.2. |
| 92 | + - If a stable version HAS BEEN RELEASED and the last released version was 1.2.3-beta.1, the new version should be 1.2.4. |
| 93 | + - If the last released version was 1.2.3, the new version should be 1.2.4. |
| 94 | + |
| 95 | +- In `CHANGELOG.md`, add the new version with the same disclaimer as in the `README.md`, along with a release date. No other changes/features added/breaking changes should be included for this version. For example: |
| 96 | + |
| 97 | +```markdown |
| 98 | +## 1.2.4 (2024-03-31) |
| 99 | + |
| 100 | +### Other Changes |
| 101 | + |
| 102 | +- This crate has been deprecated and will no longer be maintained after 12-31-2024. This crate will only receive security fixes until 12-31-2024. To receive updates on new features and non-security bug fixes, upgrade to the replacement crate, [azure_new_crate](https://crates.io/crates/azure_new_crate). Refer to the [migration guide](https://aka.ms/azsdk/rust/migrate/new-crate) for guidance on upgrading. |
| 103 | +``` |
| 104 | + |
| 105 | +### Source Code Deprecation Attributes |
| 106 | + |
| 107 | +For the main crate-level documentation, add a deprecation notice: |
| 108 | + |
| 109 | +```rust |
| 110 | +//! # Microsoft Azure SDK for Rust |
| 111 | +//! |
| 112 | +//! > **Warning**: This crate has been deprecated and will no longer be maintained after 12-31-2024. |
| 113 | +//! > To receive updates on new features and non-security bug fixes, upgrade to the replacement crate, |
| 114 | +//! > [`azure_new_crate`](https://crates.io/crates/azure_new_crate). |
| 115 | +//! |
| 116 | +//! [migration guide]: https://aka.ms/azsdk/rust/migrate/new-crate |
| 117 | + |
| 118 | +#![deprecated(since = "1.2.4", note = "This crate has been deprecated. Use azure_new_crate instead.")] |
| 119 | +``` |
| 120 | + |
| 121 | +### CI Configuration |
| 122 | + |
| 123 | +- Ensure the crate is listed in the workspace CI configuration so that the artifact is generated for release. |
| 124 | +- Consider adding the crate to a "deprecated" group in CI configurations to reduce unnecessary checks while still allowing security updates. |
| 125 | + |
| 126 | +## Step 2: Resolve all open issues/PRs corresponding to the crate |
| 127 | + |
| 128 | +If there is a replacement crate, provide a link to the new crate or an existing migration guide before closing issues and PRs. |
| 129 | + |
| 130 | +## Step 3: Create a PR |
| 131 | + |
| 132 | +Create a PR targeting the `main` branch. |
| 133 | + |
| 134 | +### Fix any CI issues |
| 135 | + |
| 136 | +Wait for the CI to run. Fix any issues related to deprecation in the PR, such as `CHANGELOG.md` or `README.md` formatting. |
| 137 | + |
| 138 | +There should not be any major test failures as deprecated crates should still function correctly. |
| 139 | + |
| 140 | +### Post your PR in the Rust review channel |
| 141 | + |
| 142 | +Post your PR in the review channel for Rust for verification that all requirements for deprecation have been met. If you are not the codeowner, please explicitly tag the codeowner in the post for approval. |
| 143 | + |
| 144 | +### Merge PR |
| 145 | + |
| 146 | +Once the PR is approved, merge. |
| 147 | + |
| 148 | +## Step 4: Publish the release |
| 149 | + |
| 150 | +### Pre-Release |
| 151 | + |
| 152 | +Before publishing, ensure all changes are properly documented and the version has been incremented correctly. |
| 153 | + |
| 154 | +### Publish the Crate |
| 155 | + |
| 156 | +Trigger the release pipeline for the crate. |
| 157 | + |
| 158 | +Note: This release DOES NOT need to be done during release week and can be done any time. |
| 159 | + |
| 160 | +### Post-Release |
| 161 | + |
| 162 | +Check to make sure that the new version of the crate has been published on crates.io and that the deprecation warnings are visible in the crate documentation. |
| 163 | + |
| 164 | +## Step 5: Create a new PR to remove the crate from the main branch |
| 165 | + |
| 166 | +After the deprecated version has been published and sufficient time has passed (typically 12 months), consider removing the crate from the main branch: |
| 167 | + |
| 168 | +- Append a note to the `README.md` deprecation message stating the crate has been removed from the main branch, with links to the latest release tag and crate on crates.io. |
| 169 | + |
| 170 | +```markdown |
| 171 | +# Microsoft Azure SDK for Rust |
| 172 | + |
| 173 | +> [!CAUTION] |
| 174 | +> This crate has been deprecated and will no longer be maintained after <EOLDate>. This crate will only receive security fixes until <EOLDate>. |
| 175 | + |
| 176 | +Crate source code and samples have been removed from the `main` branch and can be found under the release tag for the latest version. See [azure_my_crate_v1.2.4](https://github.com/Azure/azure-sdk-for-rust/tree/azure_my_crate_v1.2.4/sdk/mycrate/azure_my_crate). The latest release can be found on [crates.io](https://crates.io/crates/azure_my_crate). |
| 177 | + |
| 178 | +If you have any questions, please open a [GitHub Issue](https://github.com/Azure/azure-sdk-for-rust/issues) or contact the team. |
| 179 | +``` |
| 180 | + |
| 181 | +- Delete all files in the crate directory EXCEPT for the README.md at the crate directory root. |
| 182 | +- Remove the crate from the workspace `Cargo.toml` members list. |
| 183 | +- Remove the crate from any CI configuration files. |
| 184 | +- Create a new PR targeting the `main` branch of the repository. |
| 185 | +- Post the PR in the review channel for Rust. |
| 186 | +- Once the PR has been approved by codeowner, merge. |
| 187 | +- You're responsible for fixing any CI issues related to this PR. |
| 188 | + |
| 189 | +## Step 6: Update API Documentation |
| 190 | + |
| 191 | +### Remove the entry in the docs.rs documentation |
| 192 | + |
| 193 | +The deprecated crate will automatically show deprecation warnings on docs.rs. No manual action is typically required, as the deprecation attributes will be reflected in the generated documentation. |
| 194 | + |
| 195 | +### Update Azure SDK package resource |
| 196 | + |
| 197 | +- Create your own fork of the [azure-sdk](https://github.com/Azure/azure-sdk) repo and clone it, if you haven't already. |
| 198 | +- Create a branch in your local copy of the repo: `git checkout -b rust/azure_my_crate_deprecation` |
| 199 | +- Open the `_data/releases/latest/rust-packages.csv` file. |
| 200 | +- Find the entry for your crate and update the following fields: |
| 201 | + - `EOLDate`: In MM/DD/YYYY format. If the SDK deprecation is due to a service retirement, this date should match the service final retirement date. If there is a replacement crate, this should match the release date of the deprecated crate. |
| 202 | + - `Support`: Change the value to `deprecated`. |
| 203 | + - `Replace`: If it exists, set the value to the name of the Azure SDK for Rust crate meant to replace the crate being deprecated. If not, set the value to `NA`. |
| 204 | + - `ReplaceGuide`: If it exists, link to a migration guide in the following format: `aka.ms/azsdk/rust/migrate/<crate>`. If not, set the value to `NA`. |
| 205 | +- Note: If you are deprecating multiple crates, please wait until all deprecated crates have been published and update all entries necessary in one PR. |
| 206 | +- Create a PR to push these changes. Checks will run to notify the repo owners to review your commit. |
| 207 | + |
| 208 | +### Yank the crate on crates.io |
| 209 | + |
| 210 | +If the service is retired and users should not expect to receive any future updates, including security fixes or maintenance, your crate can be yanked from crates.io. |
| 211 | + |
| 212 | +To yank a version (use with caution): |
| 213 | + |
| 214 | +```bash |
| 215 | +cargo yank --vers 1.2.4 azure_my_crate |
| 216 | +``` |
| 217 | + |
| 218 | +Note: Yanking does not remove the crate from the index entirely, but prevents new projects from depending on it. Essentially, a yank means that all projects with a `Cargo.lock` will not break, and any future `Cargo.lock` files generated will not use the yanked version. |
| 219 | + |
| 220 | +### Update overview/conceptual documentation that points to deprecated crates |
| 221 | + |
| 222 | +Review and update any Azure documentation that references the deprecated crate: |
| 223 | + |
| 224 | +- These will be on the MS Learn page |
| 225 | +- Search for mentions of the deprecated crate in Azure documentation |
| 226 | +- Update examples and tutorials to use the replacement crate |
| 227 | +- Add migration guidance where appropriate |
| 228 | + |
| 229 | +## Additional Resources |
| 230 | + |
| 231 | +- [Azure SDK for Rust Guidelines](https://azure.github.io/azure-sdk/rust_introduction.html) |
| 232 | +- [Cargo Book - Publishing on crates.io](https://doc.rust-lang.org/cargo/reference/publishing.html) |
| 233 | +- [RFC 1270 - Deprecation](https://github.com/rust-lang/rfcs/blob/master/text/1270-deprecation.md) |
0 commit comments