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, usespacking.Version.is_prerelease
VERSION
, which is the "pretty" version string, usingstr(packing.Version)
VERSION_MAJOR_MINOR
, major and minor version numbers, e.g.1.2.3
would output1.2
See usage below for an example of how to access these values.
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: ...
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 usingGITHUB_REF
- this is mostly for testingskip_env_check
: Set to "true" to skip environment variable (e.g.GITHUB_REF
, orinput.test_github_ref
) check, mostly useful when you want to use outputs in later steps