blob: b7b5a1ae17ecbc058a237d6af1f490b27153aa30 [file] [log] [blame] [view]
AndroidX Core Team2e416b22020-12-03 22:58:07 +00001# Versioning
2
3[TOC]
4
AndroidX Core Team21ccf652022-04-01 14:53:07 +00005This page covers Jetpack's usage of Semantic Versioning and pre-release cycles,
6including the expectations at each cycle and criteria for moving to the next
7cycle or SemVer revision.
8
alanve54cc242021-02-11 13:49:33 -08009## Semantic versioning
AndroidX Core Team2e416b22020-12-03 22:58:07 +000010
alanv5e4feac2022-07-13 09:55:38 -070011Artifacts follow strict [semantic versioning](http://semver.org) for binary
12compatibility with an added inter-version sequence of pre-release revisions. The
13version for a finalized release artifact will follow the format
14`<major>.<minor>.<bugfix>` with an optional `-<alpha|beta|rc><nn>` suffix.
15Internal or nightly releases (via [androidx.dev](http://androidx.dev)) use the
16`-SNAPSHOT` suffix.
17
18### Source compatibility
19
20Libraries are encouraged -- but not required -- to preserve source compatibility
21across minor versions. Strictly requiring source compatibility would require
22major version bumps when implementing quality-of-life improvements such as
23nullability annotations or generics, which would be
24[disruptive to the library ecosystem](#major-implications).
AndroidX Core Team2e416b22020-12-03 22:58:07 +000025
alanve048d1c2021-02-11 08:46:57 -080026### Notation
AndroidX Core Team5c914c42021-02-08 17:22:57 +000027
28Major (`x.0.0`)
29: An artifact's major version indicates a guaranteed forward-compatibility
AndroidX Core Team21ccf652022-04-01 14:53:07 +000030 window. The number is incremented only when introducing breaking API or
31 behavioral changes.
AndroidX Core Team5c914c42021-02-08 17:22:57 +000032
33Minor (`1.x.0`)
34: Minor indicates compatible public API changes. This number is incremented
AndroidX Core Team21ccf652022-04-01 14:53:07 +000035 when APIs are added, including the addition of
36 [`@Deprecated` annotations](api_guidelines.md#deprecation-and-removal).
AndroidX Core Team5c914c42021-02-08 17:22:57 +000037 Binary compatibility must be preserved between minor version changes.
38
39Bugfix (`1.0.x`)
40: Bugfix indicates internal changes to address broken behavior. Care should be
41 taken to ensure that existing clients are not broken, including clients that
42 may have been working around long-standing broken behavior.
43
alanve048d1c2021-02-11 08:46:57 -080044#### Pre-release cycles
AndroidX Core Team5c914c42021-02-08 17:22:57 +000045
alanve048d1c2021-02-11 08:46:57 -080046Alpha (`1.0.0-alphaXX`)
AndroidX Core Team5c914c42021-02-08 17:22:57 +000047: Feature development and API stabilization phase.
48
alanve048d1c2021-02-11 08:46:57 -080049Beta (`1.0.0-betaXX`)
AndroidX Core Team21ccf652022-04-01 14:53:07 +000050: Functional stabilization phase. Suitable for production use.
AndroidX Core Team5c914c42021-02-08 17:22:57 +000051
alanve048d1c2021-02-11 08:46:57 -080052RC (`1.0.0-rcXX`)
AndroidX Core Team5c914c42021-02-08 17:22:57 +000053: Verification phase.
54
55Stable (no-suffix)
AndroidX Core Team21ccf652022-04-01 14:53:07 +000056: Recommended for production use.
AndroidX Core Team5c914c42021-02-08 17:22:57 +000057
AndroidX Core Team2e416b22020-12-03 22:58:07 +000058### Major (`x.0.0`) {#major}
59
60An artifact's major version indicates a guaranteed forward-compatibility window.
61For example, a developer could update an artifact versioned `2.0.0` to `2.7.3`
alanve048d1c2021-02-11 08:46:57 -080062without taking any additional action; however, updating from `2.7.3` to `3.0.0`
63may require a complete rewrite of their application or cause conflicts with
AndroidX Core Team21ccf652022-04-01 14:53:07 +000064their dependencies. Major version bumps are
65[strongly discouraged](#major-implications).
AndroidX Core Team2e416b22020-12-03 22:58:07 +000066
alanve54cc242021-02-11 13:49:33 -080067#### When to increment {#major-when}
AndroidX Core Team2e416b22020-12-03 22:58:07 +000068
69An artifact *must* increment its major version number in response to breaking
alanv5e4feac2022-07-13 09:55:38 -070070changes in binary or behavioral compatibility within the library itself *or* in
AndroidX Core Team2e416b22020-12-03 22:58:07 +000071response to breaking changes within a dependency.
72
73For example, if an artifact updates a SemVer-type dependency from `1.0.0` to
74`2.0.0` then the artifact must also bump its own major version number.
75
76An artifact *may in rare cases* increment its major version number to indicate
77an important but non-breaking change in the library. Note, however, that the
78SemVer implications of incrementing the major version are the same as a breaking
alanv5e4feac2022-07-13 09:55:38 -070079change -- dependent projects *must* assume the major version change is breaking
AndroidX Core Team2e416b22020-12-03 22:58:07 +000080and update their dependency specifications.
81
alanve54cc242021-02-11 13:49:33 -080082#### Ecosystem implications {#major-implications}
AndroidX Core Team2e416b22020-12-03 22:58:07 +000083
alanv5e4feac2022-07-13 09:55:38 -070084When an artifact increases its major version, *all* artifacts that depended on
AndroidX Core Team2e416b22020-12-03 22:58:07 +000085the previous major version are no longer considered compatible and must
86explicitly migrate to depend on the new major version.
87
88As a result, if the library ecosystem is slow to adopt a new major version of an
89artifact then developers may end up in a situation where they cannot update an
90artifact because they depend on a library that has not yet adopted the new major
91version.
92
93For this reason, we *strongly* recommend against increasing the major version of
94a “core” artifact that is depended upon by other libraries. “Leaf” artifacts --
95those that apps depend upon directly and are not used by other libraries -- have
96a much easier time increasing their major version.
97
alanve54cc242021-02-11 13:49:33 -080098#### Process requirements {#major-process}
AndroidX Core Team2e416b22020-12-03 22:58:07 +000099
100If the artifact has dependencies within Jetpack, owners *must* complete the
101assessment before implementing any breaking changes to binary or behavioral
102compatibility.
103
104Otherwise, owners are *strongly recommended* to complete the assessment before
105implementing any breaking changes to binary or behavioral compatibility, as such
106changes may negatively impact downstream clients in Android git or Google's
107repository. These clients are not part of our pre-submit workflow, but filling
108out the assessment will provide insight into how they will be affected by a
109major version change.
110
111### Minor (`1.x.0`) {#minor}
112
113Minor indicates compatible public API changes. This number is incremented when
114APIs are added, including the addition of `@Deprecated` annotations. Binary
115compatibility must be preserved between minor version changes.
116
117#### Moving between minor versions:
118
119* A change in the minor revision indicates the addition of binary-compatible
120 APIs. Libraries **must** increment their minor revision when adding APIs.
121 Dependent libraries are not required to update their minimum required
122 version unless they depend on newly-added APIs.
123
124### Bugfix (`1.0.x`) {#bugfix}
125
126Bugfix indicates internal changes to address broken behavior. Care should be
127taken to ensure that existing clients are not broken, including clients that may
128have been working around long-standing broken behavior.
129
130#### Moving between bugfix versions:
131
132* A change in the bugfix revision indicates changes in behavior to fix bugs.
133 The API surface does not change. Changes to the bugfix version may *only*
134 occur in a release branch. The bugfix revision must always be `.0` in a
135 development branch.
136
137### Pre-release suffixes {#pre-release-suffix}
138
139The pre-release suffix indicates stability and feature completeness of a
140release. A typical release will begin as alpha, move to beta after acting on
141feedback from internal and external clients, move to release candidate for final
142verification, and ultimately move to a finalized build.
143
144Alpha, beta, and release candidate releases are versioned sequentially using a
145leading zero (ex. alpha01, beta11, rc01) for compatibility with the
146lexicographic ordering of versions used by SemVer.
147
148### Snapshot {#snapshot}
149
150Snapshot releases are whatever exists at tip-of-tree. They are only subject to
151the constraints placed on the average commit. Depending on when it's cut, a
alanv5e4feac2022-07-13 09:55:38 -0700152snapshot may even be binary-identical to an `alpha`, `beta`, or `stable`
153release.
154
155### Tooling guarantees
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000156
157Versioning policies are enforced by the following Gradle tasks:
158
159`checkApi`: ensures that changes to public API are intentional and tracked,
alanv5e4feac2022-07-13 09:55:38 -0700160asking the developer to explicitly run `updateApi` (see below) if any changes
161are detected
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000162
163`checkApiRelease`: verifies that API changes between previously released and
164currently under-development versions conform to semantic versioning guarantees
165
166`updateApi`: commits API changes to source control in such a way that they can
167be reviewed in pre-submit via Gerrit API+1 and reviewed in post-submit by API
168Council
169
170`SNAPSHOT`: is automatically added to the version string for all builds that
171occur outside the build server for release branches (ex. ub-androidx-release).
172Local release builds may be forced by passing -Prelease to the Gradle command
173line.
174
175## Picking the right version {#picking-the-right-version}
176
alanv5e4feac2022-07-13 09:55:38 -0700177Libraries follow [semantic versioning](https://semver.org), which means that the
178version code is strongly tied to the API surface. A full version consists of
179revision numbers for major, minor, and bugfix as well as a pre-release stage and
180revision. Correct versioning is, for the most part, automatically enforced;
181however, please check for the following:
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000182
183### Initial version {#initial-version}
184
185If your library is brand new, your version should start at 1.0.0, e.g.
186`1.0.0-alpha01`.
187
188The initial release within a new version always starts at `alpha01`. Note the
189two-digit revision code, which allows us to do up to 99 revisions within a
190pre-release stage.
191
192### Pre-release stages
193
194A single version will typically move through several revisions within each of
195the pre-release stages: alpha, beta, rc, and stable. Subsequent revisions within
196a stage (ex. alpha, beta) are incremented by 1, ex. `alpha01` is followed by
197`alpha02` with no gaps.
198
199### Moving between pre-release stages and revisions
200
201Libraries are expected to go through a number of pre-release stages within a
202version prior to release, with stricter requirements at each stage to ensure a
203high-quality stable release. The owner for a library should typically submit a
204CL to update the stage or revision when they are ready to perform a public
205release.
206
alanv5e4feac2022-07-13 09:55:38 -0700207Libraries are expected to allow >= 2 weeks per pre-release stage. This "soaking
208period" gives developers time to try each version, find bugs, and ensure a
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000209quality stable release. Therefore, at minimum:
210
211- An `alpha` version must be publically available for 2 weeks before releasing
212 a public `beta`
213- A `beta` version must be publically available for 2 weeks before releasing
214 an public `rc`
AndroidX Core Team39791e52021-06-01 06:53:20 -0700215- A `rc` version must be publically available for 2 weeks before releasing a
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000216 public stable version
217
218Your library must meet the following criteria to move your public release to
219each stage:
220
221### Alpha {#alpha}
222
223Alpha releases are expected to be functionally stable, but may have unstable API
224surface or incomplete features. Typically, alphas have not gone through API
225Council review but are expected to have performed a minimum level of validation.
226
227#### Within the `alphaXX` cycle
228
229* API surface
230 * Prior to `alpha01` release, API tracking **must** be enabled (either
231 `publish=true` or create an `api` directory) and remain enabled
232 * May add/remove APIs within `alpha` cycle, but deprecate/remove cycle is
233 strongly recommended.
alanv5e4feac2022-07-13 09:55:38 -0700234 * May use [experimental APIs](api_guidelines.md#experimental-api) across
235 same-version group boundaries
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000236* Testing
237 * All changes **should** be accompanied by a `Test:` stanza
238 * All pre-submit and post-submit tests are passing
239 * Flaky or failing tests **must** be suppressed or fixed within one day
240 (if affecting pre-submit) or three days (if affecting post-submit)
241
242### Beta {#beta}
243
244Beta releases are ready for production use but may contain bugs. They are
245expected to be functionally stable and have highly-stable, feature-complete API
alanve048d1c2021-02-11 08:46:57 -0800246surface. All APIs should have been reviewed by API Council at this stage. Tests
247should have 100% coverage of public API surface and translations must be 100%
248complete.
249
250While beta represents API Freeze, it does not necessarily mean APIs are locked
251down permanently. A limited number of exceptions may be granted by API Council
252in cases where ship-blocking mistakes or significant user experience issues can
253be addressed with minimal changes to the API surface. Exceptions **will not** be
254granted for new features, non-trivial API changes, significant refactorings, or
255any changes likely to introduce additional functional instability. Requests for
256exceptions **must** be accompanied by a justification explaining why the change
AndroidX Core Team0db91f02021-05-06 22:45:18 +0000257cannot be made in a future minor version. This policy does not apply to
258additions of `@Experimental` APIs or changes to `@Experimental` APIs.
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000259
AndroidX Core Teamee9c1aa2021-04-06 17:29:05 +0000260#### Checklist for moving to `beta01` {#beta-checklist}
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000261
262* API surface
263 * Entire API surface has been reviewed by API Council
264 * All APIs from alpha undergoing deprecate/remove cycle must be removed
alanv5e4feac2022-07-13 09:55:38 -0700265 * The final removal of a `@Deprecated` API should occur in alpha, not
266 in beta
267 * Must not use [experimental APIs](api_guidelines.md#experimental-api)
268 across same-version group boundaries
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000269* Testing
270 * All public APIs are tested
271 * All pre-submit and post-submit tests are enabled (e.g. all suppressions
272 are removed) and passing
273 * Your library passes `./gradlew library:checkReleaseReady`
alanv5e4feac2022-07-13 09:55:38 -0700274* Use of experimental Kotlin features (e.g. `@OptIn`) must be audited for
275 stability
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000276* All dependencies are `beta`, `rc`, or stable
277* Be able to answer the question "How will developers test their apps against
278 your library?"
279 * Ideally, this is an integration app with automated tests that cover the
280 main features of the library and/or a `-testing` artifact as seen in
281 other Jetpack libraries
282
283#### Within the `betaXX` cycle
284
285* API surface
alanve54cc242021-02-11 13:49:33 -0800286 * May not add, remove, or change APIs unless granted an exception by API
287 Council following the beta API change exception request process
AndroidX Core Team0db91f02021-05-06 22:45:18 +0000288 * Must go through the full `@Deprecate` and hard-removal cycle in
289 separate `beta` releases for any exception-approved API removals or
290 changes
alanv5e4feac2022-07-13 09:55:38 -0700291 * May not remove `@RequiresOptIn` annotations from experimental APIs, as
292 this would amount to an API addition
293 * **May** add new `@RequiresOptIn` APIs and change existing experimental
AndroidX Core Team0db91f02021-05-06 22:45:18 +0000294 APIs
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000295
296### RC {#rc}
297
298Release candidates are expected to be nearly-identical to the final release, but
299may contain critical last-minute fixes for issues found during integration
300testing.
301
302#### Checklist for moving to `rc01`
303
304* All previous checklists still apply
305* Release branch, e.g. `androidx-<group_id>-release`, is created
306* API surface
307 * Any API changes from `beta` cycle are reviewed by API Council
alanv5e4feac2022-07-13 09:55:38 -0700308* No **known** `P0` or `P1` (ship-blocking) issues
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000309* All dependencies are `rc` or stable
310
311#### Within the `rcXX` cycle
312
313* Ship-blocking bug fixes only
314* All changes must have corresponding tests
315* No API changes allowed
316
317### Stable {#stable}
318
319Final releases are well-tested, both by internal tests and external clients, and
320their API surface is reviewed and finalized. While APIs may be deprecated and
321removed in future versions, any APIs added at this stage must remain for at
322least a year.
323
324#### Checklist for moving to stable
325
326* Identical to a previously released `rcXX` (note that this means any bugs
327 that result in a new release candidate will necessarily delay your stable
328 release by a minimum of two weeks)
329* No changes of any kind allowed
330* All dependencies are stable
331
332## Updating your version {#update}
333
334A few notes about version updates:
335
AndroidX Core Team408c27b2020-12-15 15:57:00 +0000336- The version of your library listed in `androidx-main` should *always* be
337 higher than the version publically available on Google Maven. This allows us
338 to do proper version tracking and API tracking.
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000339
340- Version increments must be done before the CL cutoff date (aka the build cut
341 date).
342
343- **Increments to the next stability suffix** (like `alpha` to `beta`) should
344 be handled by the library owner, with the Jetpack TPM (nickanthony@) CC'd
345 for API+1.
346
347- Version increments in release branches will need to follow the guide
348 [How to update your version on a release branch](release_branches.md#update-your-version)
349
350- When you're ready for `rc01`, the increment to `rc01` should be done in
AndroidX Core Team408c27b2020-12-15 15:57:00 +0000351 `androidx-main` and then your release branch should be snapped to that
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000352 build. See the guide [Snap your release branch](release_branches.md#snap) on
353 how to do this. After the release branch is snapped to that build, you will
AndroidX Core Team408c27b2020-12-15 15:57:00 +0000354 need to update your version in `androidx-main` to `alpha01` of the next
355 minor (or major) version.
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000356
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000357### How to update your version
358
AndroidX Core Team179f25b2022-02-04 15:20:48 -08003591. Update the version listed in `frameworks/support/libraryversions.toml`
AndroidX Core Team95cd3da2021-01-14 11:47:43 -05003601. If your library is a `beta` or `rc01` version, run `./gradlew
361 <your-lib>:updateApi`. This will create an API txt file for the new version
AndroidX Core Team21ccf652022-04-01 14:53:07 +0000362 of your library. For other versions, this step is not required
AndroidX Core Team2e416b22020-12-03 22:58:07 +00003631. Verify changes with `./gradlew checkApi verifyDependencyVersions`.
3641. Commit these change as one commit.
3651. Upload these changes to Gerrit for review.
366
367An example of a version bump can be found here:
368[aosp/833800](https://android-review.googlesource.com/c/platform/frameworks/support/+/833800)
369
370## `-ktx` Modules {#ktx}
371
AndroidX Core Team21ccf652022-04-01 14:53:07 +0000372[Kotlin extension libraries](api_guidelines.md#module-ktx) (`-ktx`) follow the
373same versioning requirements as other libraries, but with one exception: they
374must match the version of the Java libraries that they extend.
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000375
AndroidX Core Team21ccf652022-04-01 14:53:07 +0000376For example, let's say you are developing a Java library
377`androidx.foo:foo-bar:1.1.0-alpha01` and you want to add a Kotlin extension
378library `androidx.foo:foo-bar-ktx`. Your new `androidx.foo:foo-bar-ktx` library
379will start at version `1.1.0-alpha01` instead of `1.0.0-alpha01`.
AndroidX Core Team2e416b22020-12-03 22:58:07 +0000380
381If your `androidx.foo:foo-bar` module was in version `1.0.0-alpha06`, then the
AndroidX Core Team21ccf652022-04-01 14:53:07 +0000382Kotlin extension module would start in version `1.0.0-alpha06`.
alanv842f5e02022-10-11 07:25:45 -0700383
384## FAQ
385
386### When does an alpha ship?
387
388For public releases, an alpha ships when the library lead believes it is ready.
389Generally, these occur during the batched bi-weekly (every 2 weeks) release
390because all tip-of-tree dependencies will need to be released too.
391
392### Are there restrictions on when or how often an alpha can ship?
393
394Nope.
395
396### Can alpha work (ex. for the next Minor release) occur in the primary development branch during beta API lockdown?
397
398No. This is by design. Focus should be spent on improving the Beta version and
399adding documentation/samples/blog posts for usage!
400
401### Is there an API freeze window between alpha and beta while API surface is reviewed and tests are added, but before the beta is released?
402
403Yes. If any new APIs are added in this window, the beta release will be blocked
404until API review is complete and addressed.
405
406### How often can a beta release?
407
408As often as needed, however, releases outside of the bi-weekly (every 2 weeks)
409release will need to get approval from the TPM (natnaelbelay@).