diff --git a/action.yaml b/action.yaml index 6e12950..6ae018c 100644 --- a/action.yaml +++ b/action.yaml @@ -1,16 +1,19 @@ name: "check-latest-version-exists action" -description: "Check whether the latest github release/tag of a pypi package exists on a registry. If not, return the latest version" +description: "Check whether the latest GitHub release/tag of a PyPI package exists on a registry. If not, return the latest version." inputs: - github-repository: - description: "The package's Github repository name (owner/repo)" - required: true pypi-package: description: "The name of the package" required: true pypi-base-url: - description: "The pypi registry URL" + description: "The PyPI registry URL" required: true + override-version: + description: "Don't check GitHub for the latest version, use this one" + required: false + github-repository: + description: "The package's GitHub repository name (owner/repo). Required if override-version is unset" + required: false outputs: version: @@ -27,6 +30,7 @@ runs: exec python3 $GITHUB_ACTION_PATH/check.py >> $GITHUB_OUTPUT env: REPOSITORY: ${{ inputs.github-repository }} - PACKAGE: ${{ inputs.pypi-package}} - BASE_URL: ${{ inputs.pypi-base-url}} + PACKAGE: ${{ inputs.pypi-package }} + BASE_URL: ${{ inputs.pypi-base-url }} + VERSION: ${{ inputs.override-version }} diff --git a/check.py b/check.py index 2deb6b5..e4b51db 100644 --- a/check.py +++ b/check.py @@ -22,12 +22,14 @@ def does_pypi_version_exist(base_url: str, package: str, version: str) -> bool: def main(): - repository = os.environ["REPOSITORY"] package = os.environ["PACKAGE"] base_url = os.environ["BASE_URL"] - version = get_github_version(repository) - + version = os.environ.get( + "VERSION", + get_github_version(os.environ["REPOSITORY"]) + ) + if does_pypi_version_exist(base_url, package, version): sys.exit(0)