1. =====================
    
  2. How is Django Formed?
    
  3. =====================
    
  4. 
    
  5. .. highlight:: console
    
  6. 
    
  7. This document explains how to release Django.
    
  8. 
    
  9. **Please, keep these instructions up-to-date if you make changes!** The point
    
  10. here is to be descriptive, not prescriptive, so feel free to streamline or
    
  11. otherwise make changes, but **update this document accordingly!**
    
  12. 
    
  13. Overview
    
  14. ========
    
  15. 
    
  16. There are three types of releases that you might need to make:
    
  17. 
    
  18. * Security releases: disclosing and fixing a vulnerability. This'll
    
  19.   generally involve two or three simultaneous releases -- e.g.
    
  20.   1.5.x, 1.6.x, and, depending on timing, perhaps a 1.7 alpha/beta/rc.
    
  21. 
    
  22. * Regular version releases: either a final release (e.g. 1.5) or a
    
  23.   bugfix update (e.g. 1.5.1).
    
  24. 
    
  25. * Pre-releases: e.g. 1.6 alpha, beta, or rc.
    
  26. 
    
  27. The short version of the steps involved is:
    
  28. 
    
  29. #. If this is a security release, pre-notify the security distribution list
    
  30.    one week before the actual release.
    
  31. 
    
  32. #. Proofread the release notes, looking for organization and writing errors.
    
  33.    Draft a blog post and email announcement.
    
  34. 
    
  35. #. Update version numbers and create the release package(s).
    
  36. 
    
  37. #. Upload the package(s) to the ``djangoproject.com`` server.
    
  38. 
    
  39. #. Upload the new version(s) to PyPI.
    
  40. 
    
  41. #. Declare the new version in the admin on ``djangoproject.com``.
    
  42. 
    
  43. #. Post the blog entry and send out the email announcements.
    
  44. 
    
  45. #. Update version numbers post-release.
    
  46. 
    
  47. There are a lot of details, so please read on.
    
  48. 
    
  49. Prerequisites
    
  50. =============
    
  51. 
    
  52. You'll need a few things before getting started:
    
  53. 
    
  54. * A GPG key. If the key you want to use is not your default signing key, you'll
    
  55.   need to add ``-u [email protected]`` to every GPG signing command below, where
    
  56.   ``[email protected]`` is the email address associated with the key you want to
    
  57.   use.
    
  58. 
    
  59. * An install of some required Python packages::
    
  60. 
    
  61.       $ python -m pip install wheel twine
    
  62. 
    
  63. * Access to Django's record on PyPI. Create a file with your credentials:
    
  64. 
    
  65.   .. code-block:: ini
    
  66.     :caption: ``~/.pypirc``
    
  67. 
    
  68.     [pypi]
    
  69.     username:YourUsername
    
  70.     password:YourPassword
    
  71. 
    
  72. * Access to the ``djangoproject.com`` server to upload files.
    
  73. 
    
  74. * Access to the admin on ``djangoproject.com`` as a "Site maintainer".
    
  75. 
    
  76. * Access to post to ``django-announce``.
    
  77. 
    
  78. * If this is a security release, access to the pre-notification distribution
    
  79.   list.
    
  80. 
    
  81. If this is your first release, you'll need to coordinate with another releaser
    
  82. to get all these things lined up.
    
  83. 
    
  84. Pre-release tasks
    
  85. =================
    
  86. 
    
  87. A few items need to be taken care of before even beginning the release process.
    
  88. This stuff starts about a week before the release; most of it can be done
    
  89. any time leading up to the actual release:
    
  90. 
    
  91. #. If this is a security release, send out pre-notification **one week** before
    
  92.    the release. The template for that email and a list of the recipients are in
    
  93.    the private ``django-security`` GitHub wiki. BCC the pre-notification
    
  94.    recipients. Sign the email with the key you'll use for the release and
    
  95.    include `CVE IDs <https://cveform.mitre.org/>`_ (requested with Vendor:
    
  96.    djangoproject, Product: django) and patches for each issue being fixed.
    
  97.    Also, :ref:`notify django-announce <security-disclosure>` of the upcoming
    
  98.    security release.
    
  99. 
    
  100. #. As the release approaches, watch Trac to make sure no release blockers
    
  101.    are left for the upcoming release.
    
  102. 
    
  103. #. Check with the other mergers to make sure they don't have any uncommitted
    
  104.    changes for the release.
    
  105. 
    
  106. #. Proofread the release notes, including looking at the online version to
    
  107.    :ref:`catch any broken links <documentation-link-check>` or reST errors, and
    
  108.    make sure the release notes contain the correct date.
    
  109. 
    
  110. #. Double-check that the release notes mention deprecation timelines
    
  111.    for any APIs noted as deprecated, and that they mention any changes
    
  112.    in Python version support.
    
  113. 
    
  114. #. Double-check that the release notes index has a link to the notes
    
  115.    for the new release; this will be in ``docs/releases/index.txt``.
    
  116. 
    
  117. #. If this is a feature release, ensure translations from Transifex have been
    
  118.    integrated. This is typically done by a separate translation's manager
    
  119.    rather than the releaser, but here are the steps. Provided you have an
    
  120.    account on Transifex::
    
  121. 
    
  122.         $ python scripts/manage_translations.py fetch
    
  123. 
    
  124.    and then commit the changed/added files (both ``.po`` and ``.mo``).
    
  125.    Sometimes there are validation errors which need to be debugged, so avoid
    
  126.    doing this task immediately before a release is needed.
    
  127. 
    
  128. #. :ref:`Update the django-admin manual page <django-admin-manpage>`::
    
  129. 
    
  130.         $ cd docs
    
  131.         $ make man
    
  132.         $ man _build/man/django-admin.1  # do a quick sanity check
    
  133.         $ cp _build/man/django-admin.1 man/django-admin.1
    
  134. 
    
  135.    and then commit the changed man page.
    
  136. 
    
  137. #. If this is the alpha release of a new series, create a new stable branch
    
  138.    from main. For example, when releasing Django 3.1::
    
  139. 
    
  140.     $ git checkout -b stable/3.1.x origin/main
    
  141.     $ git push origin -u stable/3.1.x:stable/3.1.x
    
  142. 
    
  143.    At the same time, update the ``django_next_version`` variable in
    
  144.    ``docs/conf.py`` on the stable release branch to point to the new
    
  145.    development version. For example, when creating ``stable/4.2.x``, set
    
  146.    ``django_next_version`` to ``'5.0'`` on the new branch.
    
  147. 
    
  148. #. If this is the "dot zero" release of a new series, create a new branch from
    
  149.    the current stable branch in the `django-docs-translations
    
  150.    <https://github.com/django/django-docs-translations>`_ repository. For
    
  151.    example, when releasing Django 2.2::
    
  152. 
    
  153.     $ git checkout -b stable/2.2.x origin/stable/2.1.x
    
  154.     $ git push origin stable/2.2.x:stable/2.2.x
    
  155. 
    
  156. Preparing for release
    
  157. =====================
    
  158. 
    
  159. Write the announcement blog post for the release. You can enter it into the
    
  160. admin at any time and mark it as inactive. Here are a few examples: `example
    
  161. security release announcement`__, `example regular release announcement`__,
    
  162. `example pre-release announcement`__.
    
  163. 
    
  164. __ https://www.djangoproject.com/weblog/2013/feb/19/security/
    
  165. __ https://www.djangoproject.com/weblog/2012/mar/23/14/
    
  166. __ https://www.djangoproject.com/weblog/2012/nov/27/15-beta-1/
    
  167. 
    
  168. Actually rolling the release
    
  169. ============================
    
  170. 
    
  171. OK, this is the fun part, where we actually push out a release!
    
  172. 
    
  173. #. Check `Jenkins`__ is green for the version(s) you're putting out. You
    
  174.    probably shouldn't issue a release until it's green.
    
  175. 
    
  176.    __ https://djangoci.com
    
  177. 
    
  178. #. A release always begins from a release branch, so you should make sure
    
  179.    you're on a stable branch and up-to-date. For example::
    
  180. 
    
  181.         $ git checkout stable/1.5.x
    
  182.         $ git pull
    
  183. 
    
  184. #. If this is a security release, merge the appropriate patches from
    
  185.    ``django-security``. Rebase these patches as necessary to make each one a
    
  186.    plain commit on the release branch rather than a merge commit. To ensure
    
  187.    this, merge them with the ``--ff-only`` flag; for example::
    
  188. 
    
  189.         $ git checkout stable/1.5.x
    
  190.         $ git merge --ff-only security/1.5.x
    
  191. 
    
  192.    (This assumes ``security/1.5.x`` is a branch in the ``django-security`` repo
    
  193.    containing the necessary security patches for the next release in the 1.5
    
  194.    series.)
    
  195. 
    
  196.    If git refuses to merge with ``--ff-only``, switch to the security-patch
    
  197.    branch and rebase it on the branch you are about to merge it into (``git
    
  198.    checkout security/1.5.x; git rebase stable/1.5.x``) and then switch back and
    
  199.    do the merge. Make sure the commit message for each security fix explains
    
  200.    that the commit is a security fix and that an announcement will follow
    
  201.    (:commit:`example security commit <bf39978a53f117ca02e9a0c78b76664a41a54745>`).
    
  202. 
    
  203. #. For a feature release, remove the ``UNDER DEVELOPMENT`` header at the
    
  204.    top of the release notes and add the release date on the next line. For a
    
  205.    patch release, replace ``*Under Development*`` with the release date. Make
    
  206.    this change on all branches where the release notes for a particular version
    
  207.    are located.
    
  208. 
    
  209. #. Update the version number in ``django/__init__.py`` for the release.
    
  210.    Please see `notes on setting the VERSION tuple`_ below for details
    
  211.    on ``VERSION``.
    
  212. 
    
  213. #. If this is a pre-release package, update the "Development Status" trove
    
  214.    classifier in ``setup.cfg`` to reflect this. Otherwise, make sure the
    
  215.    classifier is set to ``Development Status :: 5 - Production/Stable``.
    
  216. 
    
  217. #. Tag the release using ``git tag``. For example::
    
  218. 
    
  219.         $ git tag --sign --message="Tag 1.5.1" 1.5.1
    
  220. 
    
  221.    You can check your work by running ``git tag --verify <tag>``.
    
  222. 
    
  223. #. Push your work, including the tag: ``git push --tags``.
    
  224. 
    
  225. #. Make sure you have an absolutely clean tree by running ``git clean -dfx``.
    
  226. 
    
  227. #. Run ``make -f extras/Makefile`` to generate the release packages. This will
    
  228.    create the release packages in a ``dist/`` directory.
    
  229. 
    
  230. #. Generate the hashes of the release packages::
    
  231. 
    
  232.         $ cd dist
    
  233.         $ md5sum *
    
  234.         $ sha1sum *
    
  235.         $ sha256sum *
    
  236. 
    
  237. #. Create a "checksums" file, ``Django-<<VERSION>>.checksum.txt`` containing
    
  238.    the hashes and release information. Start with this template and insert the
    
  239.    correct version, date, GPG key ID (from
    
  240.    ``gpg --list-keys --keyid-format LONG``), release manager's GitHub username,
    
  241.    release URL, and checksums:
    
  242. 
    
  243.    .. code-block:: text
    
  244. 
    
  245.     This file contains MD5, SHA1, and SHA256 checksums for the source-code
    
  246.     tarball and wheel files of Django <<VERSION>>, released <<DATE>>.
    
  247. 
    
  248.     To use this file, you will need a working install of PGP or other
    
  249.     compatible public-key encryption software. You will also need to have
    
  250.     the Django release manager's public key in your keyring. This key has
    
  251.     the ID ``XXXXXXXXXXXXXXXX`` and can be imported from the MIT
    
  252.     keyserver, for example, if using the open-source GNU Privacy Guard
    
  253.     implementation of PGP:
    
  254. 
    
  255.         gpg --keyserver pgp.mit.edu --recv-key XXXXXXXXXXXXXXXX
    
  256. 
    
  257.     or via the GitHub API:
    
  258. 
    
  259.         curl https://github.com/<<RELEASE MANAGER GITHUB USERNAME>>.gpg | gpg --import -
    
  260. 
    
  261.     Once the key is imported, verify this file:
    
  262. 
    
  263.         gpg --verify <<THIS FILENAME>>
    
  264. 
    
  265.     Once you have verified this file, you can use normal MD5, SHA1, or SHA256
    
  266.     checksumming applications to generate the checksums of the Django
    
  267.     package and compare them to the checksums listed below.
    
  268. 
    
  269.     Release packages:
    
  270.     =================
    
  271. 
    
  272.     https://www.djangoproject.com/m/releases/<<RELEASE TAR.GZ FILENAME>>
    
  273.     https://www.djangoproject.com/m/releases/<<RELEASE WHL FILENAME>>
    
  274. 
    
  275.     MD5 checksums:
    
  276.     ==============
    
  277. 
    
  278.     <<MD5SUM>>  <<RELEASE TAR.GZ FILENAME>>
    
  279.     <<MD5SUM>>  <<RELEASE WHL FILENAME>>
    
  280. 
    
  281.     SHA1 checksums:
    
  282.     ===============
    
  283. 
    
  284.     <<SHA1SUM>>  <<RELEASE TAR.GZ FILENAME>>
    
  285.     <<SHA1SUM>>  <<RELEASE WHL FILENAME>>
    
  286. 
    
  287.     SHA256 checksums:
    
  288.     =================
    
  289. 
    
  290.     <<SHA256SUM>>  <<RELEASE TAR.GZ FILENAME>>
    
  291.     <<SHA256SUM>>  <<RELEASE WHL FILENAME>>
    
  292. 
    
  293. #. Sign the checksum file (``gpg --clearsign --digest-algo SHA256
    
  294.    Django-<version>.checksum.txt``). This generates a signed document,
    
  295.    ``Django-<version>.checksum.txt.asc`` which you can then verify using ``gpg
    
  296.    --verify Django-<version>.checksum.txt.asc``.
    
  297. 
    
  298. If you're issuing multiple releases, repeat these steps for each release.
    
  299. 
    
  300. Making the release(s) available to the public
    
  301. =============================================
    
  302. 
    
  303. Now you're ready to actually put the release out there. To do this:
    
  304. 
    
  305. #. Upload the release package(s) to the djangoproject server, replacing
    
  306.    A.B. with the appropriate version number, e.g. 1.5 for a 1.5.x release::
    
  307. 
    
  308.         $ scp Django-* djangoproject.com:/home/www/www/media/releases/A.B
    
  309. 
    
  310.    If this is the alpha release of a new series, you will need to create the
    
  311.    directory A.B.
    
  312. 
    
  313. #. Upload the checksum file(s)::
    
  314. 
    
  315.         $ scp Django-A.B.C.checksum.txt.asc djangoproject.com:/home/www/www/media/pgp/Django-A.B.C.checksum.txt
    
  316. 
    
  317. #. Test that the release packages install correctly using ``pip``. Here's one
    
  318.    method::
    
  319. 
    
  320.         $ RELEASE_VERSION='1.7.2'
    
  321.         $ MAJOR_VERSION=`echo $RELEASE_VERSION| cut -c 1-3`
    
  322. 
    
  323.         $ python -m venv django-pip
    
  324.         $ . django-pip/bin/activate
    
  325.         $ python -m pip install https://www.djangoproject.com/m/releases/$MAJOR_VERSION/Django-$RELEASE_VERSION.tar.gz
    
  326.         $ deactivate
    
  327.         $ python -m venv django-pip-wheel
    
  328.         $ . django-pip-wheel/bin/activate
    
  329.         $ python -m pip install https://www.djangoproject.com/m/releases/$MAJOR_VERSION/Django-$RELEASE_VERSION-py3-none-any.whl
    
  330.         $ deactivate
    
  331. 
    
  332.    This just tests that the tarballs are available (i.e. redirects are up) and
    
  333.    that they install correctly, but it'll catch silly mistakes.
    
  334. 
    
  335. #. Ask a few people on IRC to verify the checksums by visiting the checksums
    
  336.    file (e.g. https://media.djangoproject.com/pgp/Django-1.5b1.checksum.txt)
    
  337.    and following the instructions in it. For bonus points, they can also unpack
    
  338.    the downloaded release tarball and verify that its contents appear to be
    
  339.    correct (proper version numbers, no stray ``.pyc`` or other undesirable
    
  340.    files).
    
  341. 
    
  342. #. Upload the release packages to PyPI (for pre-releases, only upload the wheel
    
  343.    file)::
    
  344. 
    
  345.        $ twine upload -s dist/*
    
  346. 
    
  347. #. Go to the `Add release page in the admin`__, enter the new release number
    
  348.    exactly as it appears in the name of the tarball
    
  349.    (``Django-<version>.tar.gz``). So for example enter "1.5.1" or "1.4c2", etc.
    
  350.    If the release is part of an LTS branch, mark it so.
    
  351. 
    
  352.    __ https://www.djangoproject.com/admin/releases/release/add/
    
  353. 
    
  354.    If this is the alpha release of a new series, also create a Release object
    
  355.    for the *final* release, ensuring that the *Release date* field is blank,
    
  356.    thus marking it as *unreleased*. For example, when creating the Release
    
  357.    object for ``3.1a1``, also create ``3.1`` with the Release date field blank.
    
  358. 
    
  359. #. Make the blog post announcing the release live.
    
  360. 
    
  361. #. For a new version release (e.g. 1.5, 1.6), update the default stable version
    
  362.    of the docs by flipping the ``is_default`` flag to ``True`` on the
    
  363.    appropriate ``DocumentRelease`` object in the ``docs.djangoproject.com``
    
  364.    database (this will automatically flip it to ``False`` for all
    
  365.    others); you can do this using the site's admin.
    
  366. 
    
  367.    Create new ``DocumentRelease`` objects for each language that has an entry
    
  368.    for the previous release. Update djangoproject.com's `robots.docs.txt`__
    
  369.    file by copying entries from ``manage_translations.py robots_txt`` from the
    
  370.    current stable branch in the ``django-docs-translations`` repository. For
    
  371.    example, when releasing Django 2.2::
    
  372. 
    
  373.         $ git checkout stable/2.2.x
    
  374.         $ git pull
    
  375.         $ python manage_translations.py robots_txt
    
  376. 
    
  377.    __ https://github.com/django/djangoproject.com/blob/main/djangoproject/static/robots.docs.txt
    
  378. 
    
  379. #. Post the release announcement to the |django-announce|, |django-developers|,
    
  380.    and |django-users| mailing lists. This should include a link to the
    
  381.    announcement blog post.
    
  382. 
    
  383. #. If this is a security release, send a separate email to
    
  384.    [email protected]. Provide a descriptive subject, for example,
    
  385.    "Django" plus the issue title from the release notes (including CVE ID). The
    
  386.    message body should include the vulnerability details, for example, the
    
  387.    announcement blog post text. Include a link to the announcement blog post.
    
  388. 
    
  389. #. Add a link to the blog post in the topic of the ``#django`` IRC channel:
    
  390.    ``/msg chanserv TOPIC #django new topic goes here``.
    
  391. 
    
  392. Post-release
    
  393. ============
    
  394. 
    
  395. You're almost done! All that's left to do now is:
    
  396. 
    
  397. #. Update the ``VERSION`` tuple in ``django/__init__.py`` again,
    
  398.    incrementing to whatever the next expected release will be. For
    
  399.    example, after releasing 1.5.1, update ``VERSION`` to
    
  400.    ``VERSION = (1, 5, 2, 'alpha', 0)``.
    
  401. 
    
  402. #. Add the release in `Trac's versions list`_ if necessary (and make it the
    
  403.    default by changing the ``default_version`` setting in the
    
  404.    code.djangoproject.com's `trac.ini`__, if it's a final release). The new X.Y
    
  405.    version should be added after the alpha release and the default version
    
  406.    should be updated after "dot zero" release.
    
  407. 
    
  408.    __ https://github.com/django/code.djangoproject.com/blob/main/trac-env/conf/trac.ini
    
  409. 
    
  410. #. If this was a security release, update :doc:`/releases/security` with
    
  411.    details of the issues addressed.
    
  412. 
    
  413. .. _Trac's versions list: https://code.djangoproject.com/admin/ticket/versions
    
  414. 
    
  415. New stable branch tasks
    
  416. =======================
    
  417. 
    
  418. There are several items to do in the time following the creation of a new
    
  419. stable branch (often following an alpha release). Some of these tasks don't
    
  420. need to be done by the releaser.
    
  421. 
    
  422. #. Create a new ``DocumentRelease`` object in the ``docs.djangoproject.com``
    
  423.    database for the new version's docs, and update the
    
  424.    ``docs/fixtures/doc_releases.json`` JSON fixture, so people without access
    
  425.    to the production DB can still run an up-to-date copy of the docs site.
    
  426. 
    
  427. #. Create a stub release note for the new feature version. Use the stub from
    
  428.    the previous feature release version or copy the contents from the previous
    
  429.    feature version and delete most of the contents leaving only the headings.
    
  430. 
    
  431. #. Increase the default PBKDF2 iterations in
    
  432.    ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` by about 20%
    
  433.    (pick a round number). Run the tests, and update the 3 failing
    
  434.    hasher tests with the new values. Make sure this gets noted in the
    
  435.    release notes (see the 1.8 release notes for an example).
    
  436. 
    
  437. #. Remove features that have reached the end of their deprecation cycle. Each
    
  438.    removal should be done in a separate commit for clarity. In the commit
    
  439.    message, add a "refs #XXXX" to the original ticket where the deprecation
    
  440.    began if possible.
    
  441. 
    
  442. #. Remove ``.. versionadded::``, ``.. versionadded::``, and ``.. deprecated::``
    
  443.    annotations in the documentation from two releases ago. For example, in
    
  444.    Django 1.9, notes for 1.7 will be removed.
    
  445. 
    
  446. #. Add the new branch to `Read the Docs
    
  447.    <https://readthedocs.org/projects/django/>`_. Since the automatically
    
  448.    generated version names ("stable-A.B.x") differ from the version names
    
  449.    used in Read the Docs ("A.B.x"), `create a ticket
    
  450.    <https://github.com/readthedocs/readthedocs.org/issues/5537>`_ requesting
    
  451.    the new version.
    
  452. 
    
  453. #. `Request the new classifier on PyPI
    
  454.    <https://github.com/pypa/trove-classifiers/issues/29>`_. For example
    
  455.    ``Framework :: Django :: 3.1``.
    
  456. 
    
  457. Notes on setting the VERSION tuple
    
  458. ==================================
    
  459. 
    
  460. Django's version reporting is controlled by the ``VERSION`` tuple in
    
  461. ``django/__init__.py``. This is a five-element tuple, whose elements
    
  462. are:
    
  463. 
    
  464. #. Major version.
    
  465. #. Minor version.
    
  466. #. Micro version.
    
  467. #. Status -- can be one of "alpha", "beta", "rc" or "final".
    
  468. #. Series number, for alpha/beta/RC packages which run in sequence
    
  469.    (allowing, for example, "beta 1", "beta 2", etc.).
    
  470. 
    
  471. For a final release, the status is always "final" and the series
    
  472. number is always 0. A series number of 0 with an "alpha" status will
    
  473. be reported as "pre-alpha".
    
  474. 
    
  475. Some examples:
    
  476. 
    
  477. * ``(1, 2, 1, 'final', 0)`` → "1.2.1"
    
  478. 
    
  479. * ``(1, 3, 0, 'alpha', 0)`` → "1.3 pre-alpha"
    
  480. 
    
  481. * ``(1, 3, 0, 'beta', 2)`` → "1.3 beta 2"