Skip to content

Check the release tag matches the library version before deploy.

License

Notifications You must be signed in to change notification settings

samuelcolvin/check-python-version

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Check Python Version

CI

Check the release tag matches the library version before deploy.

This is designed to be used in deploy jobs to check that GitHub release tag matches the version in your code.

The following output variables are set by the action for use in later steps:

  • IS_PRERELEASE, either 'true' or 'false' whether the version is a pre-release, uses packing.Version.is_prerelease
  • VERSION, which is the "pretty" version string, using str(packing.Version)
  • VERSION_MAJOR_MINOR, major and minor version numbers, e.g. 1.2.3 would output 1.2

See usage below for an example of how to access these values.

Usage

A minimal example:

jobs:
  deploy:
    steps:
      - ...
      - uses: samuelcolvin/check-python-version@v1
        id: check-python-version
        with:
          version_file_path: mypackage/version.py

      - run: ...

      # optionally you can use the environment variables set by the action later
      - name: publish docs
        if: '!fromJSON(steps.check-python-version.outputs.IS_PRERELEASE)'
        uses: ...

Inputs

  • version_file_path: Path to python file containing the version number string (required)
  • version_pattern: Custom regular expression to find version with, defaults to (?i)^(__version__|VERSION) *= *([\'"])v?(?P<version>.+?)\2 (which matches hatchling)
  • test_github_ref: Version to check, defaults to using GITHUB_REF - this is mostly for testing
  • skip_env_check: Set to "true" to skip environment variable (e.g. GITHUB_REF, or input.test_github_ref) check, mostly useful when you want to use outputs in later steps