Este documento descreve o processo completo para publicar o pacote juscraper no PyPI.
- Conta no PyPI: Crie uma conta em pypi.org
- Conta no Test PyPI: Crie uma conta em test.pypi.org para testes
- Trusted Publishing: Configure o Trusted Publishing no PyPI/Test PyPI
- Acesse pypi.org e faça login
- Vá para "Account settings" → "Publishing"
- Clique em "Add a new pending publisher"
- Preencha:
- PyPI Project Name:
juscraper - Owner:
jtrecenti(seu usuário do GitHub) - Repository name:
juscraper - Workflow name:
publish.yml - Environment name:
pypi
- PyPI Project Name:
Repita o processo acima em test.pypi.org com:
- Environment name:
test-pypi
# Instalar dependências de desenvolvimento
uv sync --all-extras
# Executar o script de release
uv run python scripts/release.py 0.1.0
# Fazer push das alterações
git push origin main
git push origin v0.1.0-
Atualizar versão no
pyproject.toml:version = "0.1.0"
-
Atualizar CHANGELOG.md com as mudanças da nova versão
-
Commit e tag:
git add pyproject.toml CHANGELOG.md git commit -m "chore: bump version to 0.1.0" git tag -a v0.1.0 -m "Release version 0.1.0" git push origin main git push origin v0.1.0
- Vá para GitHub Releases
- Clique em "Create a new release"
- Selecione a tag
v0.1.0 - Use o template em
.github/RELEASE_TEMPLATE.md - Publique a release
Após criar a release no GitHub:
- O workflow
publish.ymlserá executado automaticamente - Os testes serão executados em múltiplas versões do Python
- O pacote será construído
- O pacote será publicado no PyPI usando Trusted Publishing
# Executar workflow manualmente para Test PyPI
# No GitHub: Actions → Publish to PyPI → Run workflow
# Marcar "Publish to Test PyPI instead of PyPI"pip install --index-url https://test.pypi.org/simple/ juscraper==0.1.0- Verificar no PyPI: https://pypi.org/project/juscraper/
- Testar instalação:
pip install juscraper==0.1.0
- Verificar importação:
import juscraper print(juscraper.__version__)
Seguimos o Semantic Versioning:
- MAJOR (X.y.z): Mudanças incompatíveis na API
- MINOR (x.Y.z): Novas funcionalidades compatíveis
- PATCH (x.y.Z): Correções de bugs compatíveis
Se o Trusted Publishing falhar:
- Verifique se o repositório, workflow e environment estão corretos
- Certifique-se de que a release foi criada (não apenas a tag)
- Verifique os logs do workflow no GitHub Actions
Se o nome juscraper já existir:
- Escolha um novo nome único
- Atualize
pyproject.toml - Atualize todas as referências nos workflows
# Testar build localmente (gera dist/juscraper-X.Y.Z-py3-none-any.whl e dist/juscraper-X.Y.Z.tar.gz)
uv build
# Wheel nao deve conter tests/
unzip -l dist/juscraper-*.whl | grep -E '(^| )tests/' && echo "FALHA: wheel contem tests/" || echo "wheel OK"
# Sdist nao deve conter tests/
tar -tzf dist/juscraper-*.tar.gz | grep -E '(^|/)tests/' && echo "FALHA: sdist contem tests/" || echo "sdist OK"
# Tamanho esperado: wheel ~200 KB, sdist ~200 KB
ls -lh dist/A politica de empacotamento esta em [tool.hatch.build.targets.wheel] e [tool.hatch.build.targets.sdist] no pyproject.toml (allowlist explicita). O workflow .github/workflows/publish.yml valida automaticamente os artefatos antes do upload pra PyPI, mas vale rodar a checagem local antes de publicar a release no GitHub. Refs #139.