AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 1 | # Versioning |
| 2 | |
| 3 | [TOC] |
| 4 | |
alanv | e54cc24 | 2021-02-11 13:49:33 -0800 | [diff] [blame] | 5 | ## Semantic versioning |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 6 | |
| 7 | Artifacts follow strict semantic versioning. The version for a finalized release |
| 8 | will follow the format `<major>.<minor>.<bugfix>` with an optional |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 9 | `-<alpha|beta|rc><nn>` suffix. Internal or nightly releases should use the |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 10 | `-SNAPSHOT` suffix to indicate that the release bits are subject to change. |
| 11 | |
| 12 | Also check out the [Versioning FAQ](faq.md#version). |
| 13 | |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 14 | ### Notation |
AndroidX Core Team | 5c914c4 | 2021-02-08 17:22:57 +0000 | [diff] [blame] | 15 | |
| 16 | Major (`x.0.0`) |
| 17 | : An artifact's major version indicates a guaranteed forward-compatibility |
| 18 | window. For example, a developer could update an artifact versioned `2.0.0` |
| 19 | to `2.7.3` without taking any additional action. |
| 20 | |
| 21 | Minor (`1.x.0`) |
| 22 | : Minor indicates compatible public API changes. This number is incremented |
| 23 | when APIs are added, including the addition of `@Deprecated` annotations. |
| 24 | Binary compatibility must be preserved between minor version changes. |
| 25 | |
| 26 | Bugfix (`1.0.x`) |
| 27 | : Bugfix indicates internal changes to address broken behavior. Care should be |
| 28 | taken to ensure that existing clients are not broken, including clients that |
| 29 | may have been working around long-standing broken behavior. |
| 30 | |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 31 | #### Pre-release cycles |
AndroidX Core Team | 5c914c4 | 2021-02-08 17:22:57 +0000 | [diff] [blame] | 32 | |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 33 | Alpha (`1.0.0-alphaXX`) |
AndroidX Core Team | 5c914c4 | 2021-02-08 17:22:57 +0000 | [diff] [blame] | 34 | : Feature development and API stabilization phase. |
| 35 | |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 36 | Beta (`1.0.0-betaXX`) |
AndroidX Core Team | 5c914c4 | 2021-02-08 17:22:57 +0000 | [diff] [blame] | 37 | : Functional stabilization phase. |
| 38 | |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 39 | RC (`1.0.0-rcXX`) |
AndroidX Core Team | 5c914c4 | 2021-02-08 17:22:57 +0000 | [diff] [blame] | 40 | : Verification phase. |
| 41 | |
| 42 | Stable (no-suffix) |
| 43 | : Final releases are well-tested, both by internal tests and external clients, |
| 44 | and their API surface is reviewed and finalized. While APIs may be |
alanv | e54cc24 | 2021-02-11 13:49:33 -0800 | [diff] [blame] | 45 | deprecated in future versions and removed in subsequent major version bumps, |
| 46 | any APIs added at this stage should be considered semi-permanent as major |
| 47 | version bumps are [strongly discouraged](#major-implications). |
AndroidX Core Team | 5c914c4 | 2021-02-08 17:22:57 +0000 | [diff] [blame] | 48 | |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 49 | ### Major (`x.0.0`) {#major} |
| 50 | |
| 51 | An artifact's major version indicates a guaranteed forward-compatibility window. |
| 52 | For example, a developer could update an artifact versioned `2.0.0` to `2.7.3` |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 53 | without taking any additional action; however, updating from `2.7.3` to `3.0.0` |
| 54 | may require a complete rewrite of their application or cause conflicts with |
| 55 | their dependencies. |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 56 | |
alanv | e54cc24 | 2021-02-11 13:49:33 -0800 | [diff] [blame] | 57 | #### When to increment {#major-when} |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 58 | |
| 59 | An artifact *must* increment its major version number in response to breaking |
| 60 | changes in binary or behavioral compatibility within the library itself _or_ in |
| 61 | response to breaking changes within a dependency. |
| 62 | |
| 63 | For example, if an artifact updates a SemVer-type dependency from `1.0.0` to |
| 64 | `2.0.0` then the artifact must also bump its own major version number. |
| 65 | |
| 66 | An artifact *may in rare cases* increment its major version number to indicate |
| 67 | an important but non-breaking change in the library. Note, however, that the |
| 68 | SemVer implications of incrementing the major version are the same as a breaking |
| 69 | change -- dependent projects _must_ assume the major version change is breaking |
| 70 | and update their dependency specifications. |
| 71 | |
alanv | e54cc24 | 2021-02-11 13:49:33 -0800 | [diff] [blame] | 72 | #### Ecosystem implications {#major-implications} |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 73 | |
| 74 | When an artifact increases its major version, _all_ artifacts that depended on |
| 75 | the previous major version are no longer considered compatible and must |
| 76 | explicitly migrate to depend on the new major version. |
| 77 | |
| 78 | As a result, if the library ecosystem is slow to adopt a new major version of an |
| 79 | artifact then developers may end up in a situation where they cannot update an |
| 80 | artifact because they depend on a library that has not yet adopted the new major |
| 81 | version. |
| 82 | |
| 83 | For this reason, we *strongly* recommend against increasing the major version of |
| 84 | a “core” artifact that is depended upon by other libraries. “Leaf” artifacts -- |
| 85 | those that apps depend upon directly and are not used by other libraries -- have |
| 86 | a much easier time increasing their major version. |
| 87 | |
alanv | e54cc24 | 2021-02-11 13:49:33 -0800 | [diff] [blame] | 88 | #### Process requirements {#major-process} |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 89 | |
| 90 | If the artifact has dependencies within Jetpack, owners *must* complete the |
| 91 | assessment before implementing any breaking changes to binary or behavioral |
| 92 | compatibility. |
| 93 | |
| 94 | Otherwise, owners are *strongly recommended* to complete the assessment before |
| 95 | implementing any breaking changes to binary or behavioral compatibility, as such |
| 96 | changes may negatively impact downstream clients in Android git or Google's |
| 97 | repository. These clients are not part of our pre-submit workflow, but filling |
| 98 | out the assessment will provide insight into how they will be affected by a |
| 99 | major version change. |
| 100 | |
| 101 | ### Minor (`1.x.0`) {#minor} |
| 102 | |
| 103 | Minor indicates compatible public API changes. This number is incremented when |
| 104 | APIs are added, including the addition of `@Deprecated` annotations. Binary |
| 105 | compatibility must be preserved between minor version changes. |
| 106 | |
| 107 | #### Moving between minor versions: |
| 108 | |
| 109 | * A change in the minor revision indicates the addition of binary-compatible |
| 110 | APIs. Libraries **must** increment their minor revision when adding APIs. |
| 111 | Dependent libraries are not required to update their minimum required |
| 112 | version unless they depend on newly-added APIs. |
| 113 | |
| 114 | ### Bugfix (`1.0.x`) {#bugfix} |
| 115 | |
| 116 | Bugfix indicates internal changes to address broken behavior. Care should be |
| 117 | taken to ensure that existing clients are not broken, including clients that may |
| 118 | have been working around long-standing broken behavior. |
| 119 | |
| 120 | #### Moving between bugfix versions: |
| 121 | |
| 122 | * A change in the bugfix revision indicates changes in behavior to fix bugs. |
| 123 | The API surface does not change. Changes to the bugfix version may *only* |
| 124 | occur in a release branch. The bugfix revision must always be `.0` in a |
| 125 | development branch. |
| 126 | |
| 127 | ### Pre-release suffixes {#pre-release-suffix} |
| 128 | |
| 129 | The pre-release suffix indicates stability and feature completeness of a |
| 130 | release. A typical release will begin as alpha, move to beta after acting on |
| 131 | feedback from internal and external clients, move to release candidate for final |
| 132 | verification, and ultimately move to a finalized build. |
| 133 | |
| 134 | Alpha, beta, and release candidate releases are versioned sequentially using a |
| 135 | leading zero (ex. alpha01, beta11, rc01) for compatibility with the |
| 136 | lexicographic ordering of versions used by SemVer. |
| 137 | |
| 138 | ### Snapshot {#snapshot} |
| 139 | |
| 140 | Snapshot releases are whatever exists at tip-of-tree. They are only subject to |
| 141 | the constraints placed on the average commit. Depending on when it's cut, a |
| 142 | snapshot may even be binary-identical to an alpha, beta, or stable release. |
| 143 | |
| 144 | Versioning policies are enforced by the following Gradle tasks: |
| 145 | |
| 146 | `checkApi`: ensures that changes to public API are intentional and tracked, |
| 147 | asking the developer to explicitly run updateApi (see below) if any changes are |
| 148 | detected |
| 149 | |
| 150 | `checkApiRelease`: verifies that API changes between previously released and |
| 151 | currently under-development versions conform to semantic versioning guarantees |
| 152 | |
| 153 | `updateApi`: commits API changes to source control in such a way that they can |
| 154 | be reviewed in pre-submit via Gerrit API+1 and reviewed in post-submit by API |
| 155 | Council |
| 156 | |
| 157 | `SNAPSHOT`: is automatically added to the version string for all builds that |
| 158 | occur outside the build server for release branches (ex. ub-androidx-release). |
| 159 | Local release builds may be forced by passing -Prelease to the Gradle command |
| 160 | line. |
| 161 | |
| 162 | ## Picking the right version {#picking-the-right-version} |
| 163 | |
| 164 | AndroidX follows [Strict Semantic Versioning](https://semver.org), which means |
| 165 | that the version code is strongly tied to the API surface. A full version |
| 166 | consists of revision numbers for major, minor, and bugfix as well as a |
| 167 | pre-release stage and revision. Correct versioning is, for the most part, |
| 168 | automatically enforced; however, please check for the following: |
| 169 | |
| 170 | ### Initial version {#initial-version} |
| 171 | |
| 172 | If your library is brand new, your version should start at 1.0.0, e.g. |
| 173 | `1.0.0-alpha01`. |
| 174 | |
| 175 | The initial release within a new version always starts at `alpha01`. Note the |
| 176 | two-digit revision code, which allows us to do up to 99 revisions within a |
| 177 | pre-release stage. |
| 178 | |
| 179 | ### Pre-release stages |
| 180 | |
| 181 | A single version will typically move through several revisions within each of |
| 182 | the pre-release stages: alpha, beta, rc, and stable. Subsequent revisions within |
| 183 | a stage (ex. alpha, beta) are incremented by 1, ex. `alpha01` is followed by |
| 184 | `alpha02` with no gaps. |
| 185 | |
| 186 | ### Moving between pre-release stages and revisions |
| 187 | |
| 188 | Libraries are expected to go through a number of pre-release stages within a |
| 189 | version prior to release, with stricter requirements at each stage to ensure a |
| 190 | high-quality stable release. The owner for a library should typically submit a |
| 191 | CL to update the stage or revision when they are ready to perform a public |
| 192 | release. |
| 193 | |
| 194 | Libraries are expected to allow >= 2 weeks per pre-release stage. This 'soaking |
| 195 | period' gives developers time to try/use each version, find bugs, and ensure a |
| 196 | quality stable release. Therefore, at minimum: |
| 197 | |
| 198 | - An `alpha` version must be publically available for 2 weeks before releasing |
| 199 | a public `beta` |
| 200 | - A `beta` version must be publically available for 2 weeks before releasing |
| 201 | an public `rc` |
| 202 | - A `rc` version must be publically available fore 2 weeks before releasing a |
| 203 | public stable version |
| 204 | |
| 205 | Your library must meet the following criteria to move your public release to |
| 206 | each stage: |
| 207 | |
| 208 | ### Alpha {#alpha} |
| 209 | |
| 210 | Alpha releases are expected to be functionally stable, but may have unstable API |
| 211 | surface or incomplete features. Typically, alphas have not gone through API |
| 212 | Council review but are expected to have performed a minimum level of validation. |
| 213 | |
| 214 | #### Within the `alphaXX` cycle |
| 215 | |
| 216 | * API surface |
| 217 | * Prior to `alpha01` release, API tracking **must** be enabled (either |
| 218 | `publish=true` or create an `api` directory) and remain enabled |
| 219 | * May add/remove APIs within `alpha` cycle, but deprecate/remove cycle is |
| 220 | strongly recommended. |
| 221 | * Testing |
| 222 | * All changes **should** be accompanied by a `Test:` stanza |
| 223 | * All pre-submit and post-submit tests are passing |
| 224 | * Flaky or failing tests **must** be suppressed or fixed within one day |
| 225 | (if affecting pre-submit) or three days (if affecting post-submit) |
| 226 | |
| 227 | ### Beta {#beta} |
| 228 | |
| 229 | Beta releases are ready for production use but may contain bugs. They are |
| 230 | expected to be functionally stable and have highly-stable, feature-complete API |
alanv | e048d1c | 2021-02-11 08:46:57 -0800 | [diff] [blame] | 231 | surface. All APIs should have been reviewed by API Council at this stage. Tests |
| 232 | should have 100% coverage of public API surface and translations must be 100% |
| 233 | complete. |
| 234 | |
| 235 | While beta represents API Freeze, it does not necessarily mean APIs are locked |
| 236 | down permanently. A limited number of exceptions may be granted by API Council |
| 237 | in cases where ship-blocking mistakes or significant user experience issues can |
| 238 | be addressed with minimal changes to the API surface. Exceptions **will not** be |
| 239 | granted for new features, non-trivial API changes, significant refactorings, or |
| 240 | any changes likely to introduce additional functional instability. Requests for |
| 241 | exceptions **must** be accompanied by a justification explaining why the change |
AndroidX Core Team | 0db91f0 | 2021-05-06 22:45:18 +0000 | [diff] [blame] | 242 | cannot be made in a future minor version. This policy does not apply to |
| 243 | additions of `@Experimental` APIs or changes to `@Experimental` APIs. |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 244 | |
AndroidX Core Team | ee9c1aa | 2021-04-06 17:29:05 +0000 | [diff] [blame] | 245 | #### Checklist for moving to `beta01` {#beta-checklist} |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 246 | |
| 247 | * API surface |
| 248 | * Entire API surface has been reviewed by API Council |
| 249 | * All APIs from alpha undergoing deprecate/remove cycle must be removed |
AndroidX Core Team | 0db91f0 | 2021-05-06 22:45:18 +0000 | [diff] [blame] | 250 | * The final removal of a `@Deprecated` API must occur in alpha, not in |
| 251 | Beta. |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 252 | * Testing |
| 253 | * All public APIs are tested |
| 254 | * All pre-submit and post-submit tests are enabled (e.g. all suppressions |
| 255 | are removed) and passing |
| 256 | * Your library passes `./gradlew library:checkReleaseReady` |
| 257 | * No experimental features (e.g. `@UseExperimental`) may be used |
| 258 | * All dependencies are `beta`, `rc`, or stable |
| 259 | * Be able to answer the question "How will developers test their apps against |
| 260 | your library?" |
| 261 | * Ideally, this is an integration app with automated tests that cover the |
| 262 | main features of the library and/or a `-testing` artifact as seen in |
| 263 | other Jetpack libraries |
| 264 | |
| 265 | #### Within the `betaXX` cycle |
| 266 | |
| 267 | * API surface |
alanv | e54cc24 | 2021-02-11 13:49:33 -0800 | [diff] [blame] | 268 | * May not add, remove, or change APIs unless granted an exception by API |
| 269 | Council following the beta API change exception request process |
AndroidX Core Team | 0db91f0 | 2021-05-06 22:45:18 +0000 | [diff] [blame] | 270 | * Must go through the full `@Deprecate` and hard-removal cycle in |
| 271 | separate `beta` releases for any exception-approved API removals or |
| 272 | changes |
| 273 | * May not remove `@Experimental` from experimental APIs, as this would |
| 274 | amount to an API addition |
| 275 | * **May** add new `@Experimental` APIs and change existing `@Experimental` |
| 276 | APIs |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 277 | |
| 278 | ### RC {#rc} |
| 279 | |
| 280 | Release candidates are expected to be nearly-identical to the final release, but |
| 281 | may contain critical last-minute fixes for issues found during integration |
| 282 | testing. |
| 283 | |
| 284 | #### Checklist for moving to `rc01` |
| 285 | |
| 286 | * All previous checklists still apply |
| 287 | * Release branch, e.g. `androidx-<group_id>-release`, is created |
| 288 | * API surface |
| 289 | * Any API changes from `beta` cycle are reviewed by API Council |
| 290 | * No **known** P0 or P1 (ship-blocking) issues |
| 291 | * All dependencies are `rc` or stable |
| 292 | |
| 293 | #### Within the `rcXX` cycle |
| 294 | |
| 295 | * Ship-blocking bug fixes only |
| 296 | * All changes must have corresponding tests |
| 297 | * No API changes allowed |
| 298 | |
| 299 | ### Stable {#stable} |
| 300 | |
| 301 | Final releases are well-tested, both by internal tests and external clients, and |
| 302 | their API surface is reviewed and finalized. While APIs may be deprecated and |
| 303 | removed in future versions, any APIs added at this stage must remain for at |
| 304 | least a year. |
| 305 | |
| 306 | #### Checklist for moving to stable |
| 307 | |
| 308 | * Identical to a previously released `rcXX` (note that this means any bugs |
| 309 | that result in a new release candidate will necessarily delay your stable |
| 310 | release by a minimum of two weeks) |
| 311 | * No changes of any kind allowed |
| 312 | * All dependencies are stable |
| 313 | |
| 314 | ## Updating your version {#update} |
| 315 | |
| 316 | A few notes about version updates: |
| 317 | |
AndroidX Core Team | 408c27b | 2020-12-15 15:57:00 +0000 | [diff] [blame] | 318 | - The version of your library listed in `androidx-main` should *always* be |
| 319 | higher than the version publically available on Google Maven. This allows us |
| 320 | to do proper version tracking and API tracking. |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 321 | |
| 322 | - Version increments must be done before the CL cutoff date (aka the build cut |
| 323 | date). |
| 324 | |
| 325 | - **Increments to the next stability suffix** (like `alpha` to `beta`) should |
| 326 | be handled by the library owner, with the Jetpack TPM (nickanthony@) CC'd |
| 327 | for API+1. |
| 328 | |
| 329 | - Version increments in release branches will need to follow the guide |
| 330 | [How to update your version on a release branch](release_branches.md#update-your-version) |
| 331 | |
| 332 | - When you're ready for `rc01`, the increment to `rc01` should be done in |
AndroidX Core Team | 408c27b | 2020-12-15 15:57:00 +0000 | [diff] [blame] | 333 | `androidx-main` and then your release branch should be snapped to that |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 334 | build. See the guide [Snap your release branch](release_branches.md#snap) on |
| 335 | how to do this. After the release branch is snapped to that build, you will |
AndroidX Core Team | 408c27b | 2020-12-15 15:57:00 +0000 | [diff] [blame] | 336 | need to update your version in `androidx-main` to `alpha01` of the next |
| 337 | minor (or major) version. |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 338 | |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 339 | |
| 340 | ### How to update your version |
| 341 | |
| 342 | 1. Update the version listed in |
| 343 | `frameworks/support/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt` |
AndroidX Core Team | 95cd3da | 2021-01-14 11:47:43 -0500 | [diff] [blame] | 344 | 1. If your library is a `beta` or `rc01` version, run `./gradlew |
| 345 | <your-lib>:updateApi`. This will create an API txt file for the new version |
| 346 | of your library. For other versions, this step is not reqired |
AndroidX Core Team | 2e416b2 | 2020-12-03 22:58:07 +0000 | [diff] [blame] | 347 | 1. Verify changes with `./gradlew checkApi verifyDependencyVersions`. |
| 348 | 1. Commit these change as one commit. |
| 349 | 1. Upload these changes to Gerrit for review. |
| 350 | |
| 351 | An example of a version bump can be found here: |
| 352 | [aosp/833800](https://android-review.googlesource.com/c/platform/frameworks/support/+/833800) |
| 353 | |
| 354 | ## `-ktx` Modules {#ktx} |
| 355 | |
| 356 | Kotlin Extension modules (`-ktx`) for regular Java modules follow the same |
| 357 | requirements, but with one exception. They must match the version of the Java |
| 358 | module that they extend. |
| 359 | |
| 360 | For example, let's say you are developing a java library |
| 361 | `androidx.foo:foo-bar:1.1.0-alpha01` and you want to add a kotlin extension |
| 362 | module `androidx.foo:foo-bar-ktx` module. Your new `androidx.foo:foo-bar-ktx` |
| 363 | module will start at version `1.1.0-alpha01` instead of `1.0.0-alpha01`. |
| 364 | |
| 365 | If your `androidx.foo:foo-bar` module was in version `1.0.0-alpha06`, then the |
| 366 | kotlin extension module would start in version `1.0.0-alpha06`. |