Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate Versioning, Release, and PyPI Publishing #425

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Commits on Dec 8, 2023

  1. Add a post-commit hook for automatic tagging

    **TL;DR: this post-commit hook ensures that valid versions are automatically tagged based on changes in the `pyproject.toml` file.**
    
    This post-commit hook automates the tagging of the project based on changes in the `pyproject.toml` file. Here's a breakdown of what it does:
    
    **1. Extracting the version number:**
    
    * `git diff HEAD^..HEAD`: This line compares the current commit (`HEAD`) to its immediate predecessor (`HEAD^`).
    * `-- "$(git rev-parse --show-toplevel)"/pyproject.toml`: This specifies the `pyproject.toml` file within the project root directory.
    * `grep -m 1 '^\+.*version'`: This searches for the first line starting with a "+" and containing the word "version".
    * `sed -s 's/[^A-Z0-9\.\-]//g'`: This removes any characters except numbers, letters, dots, and hyphens from the matched line.
    * `version=`: Finally, the extracted version string is stored in the `version` variable.
    
    **2. Validating the version format:**
    
    * `if [[ ! $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(\-[A-Z]+\.[0-9]+)?$ ]]; then`: This checks if the extracted version string matches a specific format:
        * `^`: Starts with the beginning of the string.
        * `([0-9]+)`: Matches one or more digits (major version).
        * `\.`: Matches a literal dot.
        * `([0-9]+)`: Matches one or more digits (minor version).
        * `\.`: Matches a literal dot.
        * `([0-9]+)`: Matches one or more digits (patch version).
        * `(\-[A-Z]+\.[0-9]+)?`: This is optional and matches a hyphen followed by one or more uppercase letters and a dot and another number (pre-release + build information).
        * `$`: Matches the end of the string.
    * If the format is invalid, it logs a message and exits with an error code.
    
    **3. Creating the tag:**
    
    * `git tag -a "v$version"`: This creates a new annotated tag named `v$version` (with the prefix "v") using the extracted version number.
    * ``-m "`git log -1 --format=%s`"``: This sets the tag message with the full commit message of the current commit.
    * `echo "Created a new tag, v$version"`: This prints a confirmation message.
    
    Co-authored-by: Darwish Ahmad Herati <[email protected]>
    fredgrub and herati committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    4a88a2f View commit details
    Browse the repository at this point in the history
  2. Add action to make a release and publish to PyPI

    This GitHub Actions workflow automates two tasks:
    
    1. **Create Release:**
       - Triggered when a new version tag (formatted as `vX.X.X`) is pushed.
       - Creates a release with the tag name, marking it as the latest version.
    
    2. **Publish to PyPI:**
       - Runs after the release is created successfully.
       - Builds and publishes the Python package to PyPI using Poetry.
       - Ignores development requirements during the publishing process.
    
    This ensures that each new version gets a release on GitHub and the corresponding Python package is published on PyPI.
    
    Co-authored-by: Darwish Ahmad Herati <[email protected]>
    Co-authored-by: mateuslatrova <[email protected]>
    3 people committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    125ee2b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    089db96 View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2023

  1. Update CONTRIBUTING.rst file

    - Add instructions to setup git-hooks and poetry-bumpversion plugin
    fredgrub committed Dec 10, 2023
    Configuration menu
    Copy the full SHA
    703d809 View commit details
    Browse the repository at this point in the history