Skip to content

feat: pipeline for autopublish

Pelayo García requested to merge ci/auto-publish into main

PyPI Release Pipeline for GitLab

This GitLab pipeline is designed to automate the process of creating a new PyPI release whenever a new tag is pushed. The pipeline is composed of three stages: install, build, and upload.

Prerequisites

  • You should have the necessary permissions to push tags and execute pipelines in your GitLab repository.
  • You should have a PyPI account with the necessary permissions to upload packages. The username and password should be stored in the PYPI_USERNAME and PYPI_PASSWORD GitLab CI/CD variables.

Pipeline Stages

  1. Install: Installs the necessary dependencies (twine, wheel, setuptools-odoo) into a Python virtual environment.

  2. Build: Prepares each modified Odoo module for PyPI release by generating setup.py files, builds the distribution files for these modules.

  3. Upload: Uploads the distribution files to PyPI.

Configuration

  1. The pipeline uses the gitlab CI/CD variables GIT_MAIL and GIT_NAME in the prepare job script. These are used to set the Git user email and name for the commits made by the setuptools-odoo-make-default command.

  2. The pipeline uses the GitLab CI/CD variables PYPI_NAME and PYPI_TOKEN to authenticate with PyPI during the upload job. These should be set to your PyPI username and password.

Behavior

The pipeline only runs when a new tag is pushed to the repository. For each Odoo module that has been modified in the commit associated with the tag, it generates setup.py files, builds the distribution files, and uploads them to PyPI. This means that only modified modules will get new PyPI releases.

Note

This pipeline assumes that each Odoo module resides in its own directory at the root level of the repository. If your repository's structure is different, you might need to adjust the script accordingly.

Merge request reports