Como o Django é formado?

Este documento explica como fazer uma release do Django.

Por favor, mantenha essas instruções atualizadas se você fizer mudanças! A ideia aqui é ser descritivo, não prescritivo, então sinta-se à vontade para agilizar ou por outro lado fazer mudanças, mas atualize este documento de acordo

Visão Geral

Existem três tipos de releases que você pode precisar fazer:

  • Security releases: disclosing and fixing a vulnerability. This’ll generally involve two or three simultaneous releases – e.g. 3.2.x, 4.0.x, and, depending on timing, perhaps a 4.1.x.
  • Regular version releases: either a final release (e.g. 4.1) or a bugfix update (e.g. 4.1.1).
  • Pre-releases: e.g. 4.2 alpha, beta, or rc.

Uma curta versão dos passos envolvidos é a seguinte:

  1. Se esta é uma release de segurança, pre-notificar a lista de distribuição de segurança uma semana antes da release atual.
  2. Revisar as notas de release, buscando por melhor organização e erros de escrita. Esboçar um post de blog e um e-mail de anúncio.
  3. Atualizar os números de versão e criar um ou mais pacotes de release.
  4. Fazer upload do pacote (ou dos pacotes) para o servidor djangoproject.com.
  5. Verify package(s) signatures, check if they can be installed, and ensure minimal functionality.
  6. Fazer upload da nova versão (ou versões) para o PyPI.
  7. Declare a nova versão no admin em djangoproject.com.
  8. Postar a entrada no blog e enviar os anúncios de e-mail.
  9. Atualizar os números de versão pós-release.

Existem vários detalhes, então por favor continue lendo.

Pré-requisitos

Você vai precisar de algumas coisas antes de começar:

  • A GPG key. If the key you want to use is not your default signing key, you’ll need to add -u you@example.com to every GPG signing command below, where you@example.com is the email address associated with the key you want to use. You will also need to add -i you@example.com to the twine call.

  • An install of some required Python packages:

    $ python -m pip install wheel twine
    
  • Access to Django’s project on PyPI. Create a project-scoped token following the official documentation and set up your $HOME/.pypirc file like this:

    ~/.pypirc
    [distutils]
      index-servers =
        pypi
        django
    
    [pypi]
      username = __token__
      password = # User-scoped or project-scoped token, to set as the default.
    
    [django]
      repository = https://upload.pypi.org/legacy/
      username = __token__
      password = # A project token.
    
  • Acessar o servidor de djangoproject.com para atualizar os arquivos.

  • Acesso para o admin em djangoproject.com como um “Site maintainer”.

  • Acesso para postar em django-announce.

  • Se essa é uma release de segurança, acesso para a lista de distribuição de segurança.

If this is your first release, you’ll need to coordinate with another releaser to get all these things lined up.

Tarefas de pré-release

Alguns itens precisam ser realizados antes mesmo de começar o processo de release. Isso começa por volta de uma semana antes da release; a maior parte dele pode ser feita a qualquer momento culminando na release em si:

  1. If this is a security release, send out pre-notification one week before the release. The template for that email and a list of the recipients are in the private django-security GitHub wiki. BCC the pre-notification recipients. Sign the email with the key you’ll use for the release and include CVE IDs (requested with Vendor: djangoproject, Product: django) and patches for each issue being fixed. Also, notify django-announce of the upcoming security release.

  2. À medida em que a release se aproxima, acompanhe o Track para se certificar de que nenhum problema que possa bloquear a release prestes a ser lançada tenha restado sem solução.

  3. Check with the other mergers to make sure they don’t have any uncommitted changes for the release.

  4. Proofread the release notes, including looking at the online version to catch any broken links or reST errors, and make sure the release notes contain the correct date.

  5. Verifique duas vezes as menções de depreciação ao longo do tempo nas notas da release em busca de quaisquer APIs listadas como depreciadas, e que as notas mencionam quaisquer mudanças na versão suportada do Python.

  6. Verifique duas vezes se o índice das notas de release possuem um link para as notas da nova release; isso estará em docs/releases/index.txt.

  7. If this is a feature release, ensure translations from Transifex have been integrated. This is typically done by a separate translation’s manager rather than the releaser, but here are the steps. Provided you have an account on Transifex:

    $ python scripts/manage_translations.py fetch
    

    and then commit the changed/added files (both .po and .mo). Sometimes there are validation errors which need to be debugged, so avoid doing this task immediately before a release is needed.

  8. Update the django-admin manual page:

    $ cd docs
    $ make man
    $ man _build/man/django-admin.1  # do a quick sanity check
    $ cp _build/man/django-admin.1 man/django-admin.1
    

    e então faça commit da página man alterada.

  9. If this is the alpha release of a new series, create a new stable branch from main. For example, when releasing Django 4.2:

    $ git checkout -b stable/4.2.x origin/main
    $ git push origin -u stable/4.2.x:stable/4.2.x
    

    At the same time, update the django_next_version variable in docs/conf.py on the stable release branch to point to the new development version. For example, when creating stable/4.2.x, set django_next_version to '5.0' on the new branch.

  10. If this is the “dot zero” release of a new series, create a new branch from the current stable branch in the django-docs-translations repository. For example, when releasing Django 4.2:

    $ git checkout -b stable/4.2.x origin/stable/4.1.x
    $ git push origin stable/4.2.x:stable/4.2.x
    

Preparando para a release

Escreva o post no blog para o anúncio da release. Você pode entrar dentro do admin a qualquer momento e marcar ele como inativo. Aqui vão alguns exemplos: example security release announcement, example regular release announcement, example pre-release announcement.

Lançando a release

OK, esta é a parte divertida, quando nós efetivamente fazemos o push da release!

  1. Veja se o status do Jenkins é verde para a versão (ou versões) que você está soltando. Você provavelmente não deve lançar uma release enquanto ele não estiver com o status verde.

  2. A release always begins from a release branch, so you should make sure you’re on a stable branch and up-to-date. For example:

    $ git checkout stable/4.1.x
    $ git pull
    
  3. If this is a security release, merge the appropriate patches from django-security. Rebase these patches as necessary to make each one a plain commit on the release branch rather than a merge commit. To ensure this, merge them with the --ff-only flag; for example:

    $ git checkout stable/4.1.x
    $ git merge --ff-only security/4.1.x
    

    (This assumes security/4.1.x is a branch in the django-security repo containing the necessary security patches for the next release in the 4.1 series.)

    If git refuses to merge with --ff-only, switch to the security-patch branch and rebase it on the branch you are about to merge it into (git checkout security/4.1.x; git rebase stable/4.1.x) and then switch back and do the merge. Make sure the commit message for each security fix explains that the commit is a security fix and that an announcement will follow (example security commit).

  4. For a feature release, remove the UNDER DEVELOPMENT header at the top of the release notes and add the release date on the next line. For a patch release, remove the Expected prefix and update the release date, if necessary. Make this change on all branches where the release notes for a particular version are located.

  5. Atualize o número da versão em django/__init__.py para a release. Por favor veja as notas sobre configurando a tupla VERSION abaixo para mais detalhes sobre VERSION.

  6. If this is a pre-release package, update the “Development Status” trove classifier in setup.cfg to reflect this. Otherwise, make sure the classifier is set to Development Status :: 5 - Production/Stable.

  7. Tag the release using git tag. For example:

    $ git tag --sign --message="Tag 4.1.1" 4.1.1
    

    Você pode checar o seu trabalho rodando o comando git tag --verify <tag>.

  8. Faça o push do seu trabalho, incluindo a tag: git push --tags.

  9. Certifique-se de que você tem uma árvore absolutamente limpa rodando o comando git clean -dfx`.

  10. Rodar make -f extras/Makefile para gerar os pacotes da release. Isso criará os pacotes da release no diretório dist/;

  11. Generate the hashes of the release packages:

    $ cd dist
    $ md5sum *
    $ sha1sum *
    $ sha256sum *
    
  12. Create a “checksums” file, Django-<<VERSION>>.checksum.txt containing the hashes and release information. Start with this template and insert the correct version, date, GPG key ID (from gpg --list-keys --keyid-format LONG), release manager’s GitHub username, release URL, and checksums:

    This file contains MD5, SHA1, and SHA256 checksums for the source-code
    tarball and wheel files of Django <<VERSION>>, released <<DATE>>.
    
    To use this file, you will need a working install of PGP or other
    compatible public-key encryption software. You will also need to have
    the Django release manager's public key in your keyring. This key has
    the ID ``XXXXXXXXXXXXXXXX`` and can be imported from the MIT
    keyserver, for example, if using the open-source GNU Privacy Guard
    implementation of PGP:
    
        gpg --keyserver pgp.mit.edu --recv-key XXXXXXXXXXXXXXXX
    
    or via the GitHub API:
    
        curl https://github.com/<<RELEASE MANAGER GITHUB USERNAME>>.gpg | gpg --import -
    
    Once the key is imported, verify this file:
    
        gpg --verify <<THIS FILENAME>>
    
    Once you have verified this file, you can use normal MD5, SHA1, or SHA256
    checksumming applications to generate the checksums of the Django
    package and compare them to the checksums listed below.
    
    Release packages
    ================
    
    https://www.djangoproject.com/m/releases/<<MAJOR VERSION>>/<<RELEASE TAR.GZ FILENAME>>
    https://www.djangoproject.com/m/releases/<<MAJOR VERSION>>/<<RELEASE WHL FILENAME>>
    
    MD5 checksums
    =============
    
    <<MD5SUM>>  <<RELEASE TAR.GZ FILENAME>>
    <<MD5SUM>>  <<RELEASE WHL FILENAME>>
    
    SHA1 checksums
    ==============
    
    <<SHA1SUM>>  <<RELEASE TAR.GZ FILENAME>>
    <<SHA1SUM>>  <<RELEASE WHL FILENAME>>
    
    SHA256 checksums
    ================
    
    <<SHA256SUM>>  <<RELEASE TAR.GZ FILENAME>>
    <<SHA256SUM>>  <<RELEASE WHL FILENAME>>
    
  13. Assine o arquivo de checksum (gpg --clearsign --digest-algo SHA256 Django-<version>.checksum.txt). Isso gera um documento assinado, Django-<version>.checksum.txt.asc que você pode então verificar usando gpg --verify Django-<version>.checksum.txt.asc.

Se você estiver lançando múltiplas releases, repita esses passos para cada release.

Fazendo a release (ou as releases) disponível ao público

Agora você está pronto para lançar a release efetivamente. Para isso faça:

  1. Upload the release package(s) to the djangoproject server, replacing A.B. with the appropriate version number, e.g. 4.1 for a 4.1.x release:

    $ scp Django-* djangoproject.com:/home/www/www/media/releases/A.B
    

    If this is the alpha release of a new series, you will need to create the directory A.B.

  2. Upload the checksum file(s):

    $ scp Django-A.B.C.checksum.txt.asc djangoproject.com:/home/www/www/media/pgp/Django-A.B.C.checksum.txt
    
  3. Test that the release packages install correctly using pip. Here’s one method:

    $ RELEASE_VERSION='4.1.1'
    $ MAJOR_VERSION=`echo $RELEASE_VERSION| cut -c 1-3`
    
    $ python -m venv django-pip
    $ . django-pip/bin/activate
    $ python -m pip install https://www.djangoproject.com/m/releases/$MAJOR_VERSION/Django-$RELEASE_VERSION.tar.gz
    $ deactivate
    $ python -m venv django-pip-wheel
    $ . django-pip-wheel/bin/activate
    $ python -m pip install https://www.djangoproject.com/m/releases/$MAJOR_VERSION/Django-$RELEASE_VERSION-py3-none-any.whl
    $ deactivate
    

    Isso só verifica se as tarballs estão disponíveis (ex. redirecionamentos estão funcionando) e que eles instalaram corretamente, mas eles irão pegar erros bobos.

  4. Run the confirm-release build on Jenkins to verify the checksum file(s) (e.g. use 4.2rc1 for https://media.djangoproject.com/pgp/Django-4.2rc1.checksum.txt).

  5. Upload the release packages to PyPI (for pre-releases, only upload the wheel file):

    $ twine upload -s dist/*
    
  6. Go to the Add release page in the admin, enter the new release number exactly as it appears in the name of the tarball (Django-<version>.tar.gz). So for example enter “4.1.1” or “4.2rc1”, etc. If the release is part of an LTS branch, mark it so.

    If this is the alpha release of a new series, also create a Release object for the final release, ensuring that the Release date field is blank, thus marking it as unreleased. For example, when creating the Release object for 4.2a1, also create 4.2 with the Release date field blank.

  7. Faça um post no blog anunciando que a release foi lançada.

  8. For a new version release (e.g. 4.1, 4.2), update the default stable version of the docs by flipping the is_default flag to True on the appropriate DocumentRelease object in the docs.djangoproject.com database (this will automatically flip it to False for all others); you can do this using the site’s admin.

    Create new DocumentRelease objects for each language that has an entry for the previous release. Update djangoproject.com’s robots.docs.txt file by copying entries from manage_translations.py robots_txt from the current stable branch in the django-docs-translations repository. For example, when releasing Django 4.2:

    $ git checkout stable/4.2.x
    $ git pull
    $ python manage_translations.py robots_txt
    
  9. Post the release announcement to the django-announce, django-developers, django-users mailing lists, and the Django Forum. This should include a link to the announcement blog post.

  10. If this is a security release, send a separate email to oss-security@lists.openwall.com. Provide a descriptive subject, for example, “Django” plus the issue title from the release notes (including CVE ID). The message body should include the vulnerability details, for example, the announcement blog post text. Include a link to the announcement blog post.

  11. Add a link to the blog post in the topic of the #django IRC channel: /msg chanserv TOPIC #django new topic goes here.

Pós-release

Você quase terminou! Tudo que resta a fazer agora é:

  1. Update the VERSION tuple in django/__init__.py again, incrementing to whatever the next expected release will be. For example, after releasing 4.1.1, update VERSION to VERSION = (4, 1, 2, 'alpha', 0).
  2. Add the release in Trac’s versions list if necessary (and make it the default by changing the default_version setting in the code.djangoproject.com’s trac.ini, if it’s a final release). The new X.Y version should be added after the alpha release and the default version should be updated after “dot zero” release.
  3. If it’s a final release, update the current stable branch and remove the pre-release branch in the Django release process on Trac.
  4. Se essa for uma release de segurança, atualize Archive of security issues com detalhes dos problemas endereçados.

Tarefas para novas branches estáveis

Existem várias coisas para fazer no momento posterior a criação de uma nova branch estável (geralmente após uma alpha release). Algumas dessas tarefas não precisam ser feitas pelo releaser.

  1. Crie um novo objeto DocumentRelease no banco de dados de docs.djangoproject.com para a nova versão da documentação, e atualize o JSON fixture docs/fixtures/doc_releases.json, para que pessoas sem acesso ao DB de produção possam ainda rodar uma cópia atualizada do site da documentação.
  2. Criar um esboço de uma nota de release para a nova versão. Use o esboço de versões de releases anteriores ou copie os conteúdos de versões prévias e exclua a maior parte do conteúdo deixando apenas os cabeçalhos.
  3. Increase the default PBKDF2 iterations in django.contrib.auth.hashers.PBKDF2PasswordHasher by about 20% (pick a round number). Run the tests, and update the 3 failing hasher tests with the new values. Make sure this gets noted in the release notes (see the 4.1 release notes for an example).
  4. Remova as funcionalidades que chegaram ao fim de seu clico de depreciação. Cada remoção deve ser feita em um commit separado para claridade. Na mensagem de commit, adiciona um “refs #XXXX” para o ticket original onde a depreciação começou se possível.
  5. Remove .. versionadded::, .. versionadded::, and .. deprecated:: annotations in the documentation from two releases ago. For example, in Django 4.2, notes for 4.0 will be removed.
  6. Add the new branch to Read the Docs. Since the automatically generated version names (“stable-A.B.x”) differ from the version names used in Read the Docs (“A.B.x”), create a ticket requesting the new version.
  7. Request the new classifier on PyPI. For example Framework :: Django :: 3.1.
  8. Update the current branch under active development and add pre-release branch in the Django release process on Trac.

Considerações quanto a configuração da tupla VERSION

O reporte de versões do Django é controlado por uma tupla VERSION em django/__init__.py. Essa é uma tupla de cinco elementos, cujos elementos são:

  1. Versão principal.
  2. Versão secundária.
  3. Micro versão.
  4. Status – pode ser “alpha”, “beta”, “rc” ou “final”.
  5. Número das séries, para alpha/beta/RC packages que rodam em sequência (permitindo, por exemplo, “beta 1”, “beta 2”, etc.).

Para uma release final, o status é sempre “final” e o número das séries é sempre 0. Um número de séries 0 com um status “alpha” será reportado como “pre-alpha”.

Alguns exemplos:

  • (4, 1, 1, "final", 0) → “4.1.1”
  • (4, 2, 0, "alpha", 0) → “4.2 pre-alpha”
  • (4, 2, 0, "beta", 1) → “4.2 beta 1”
Back to Top