Skip to content

Commit

Permalink
Add a new max-versions option
Browse files Browse the repository at this point in the history
  • Loading branch information
TGWolf committed May 14, 2024
1 parent 12408ab commit 6231958
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ To use the action, simply throw this into one of your workflows
language: "python"
min-version: 3.7 # not required - defaults to "EOL"
max-version: 3.10 # not required - defaults to latest
max-versions: 0 # not required - defaults to latest
include-prereleases: true # not required - defaults to false
highest-only: true # not required - defaults to false
remove-patch-version: true # not required - defaults to false
Expand All @@ -82,6 +83,7 @@ ${{ steps.get-versions.outputs.latest-versions }}
| language | Yes | | Go, Node, Perl, PHP, Python, Ruby or Terraform. |
| min-version | No | "EOL" | semver, "EOL" or "ALL" |
| max-version | No | "latest" | semver or "latest" |
| max-versions | No | 0 | 0-N (N is number of versions to return. |
| include-prereleases | No | false | true or false |
| highest-only | No | false | true or false |
| remove-patch-version | No | false | true or false |
Expand Down Expand Up @@ -167,4 +169,4 @@ jobs:


<br />
<p align="right"><a href="https://wolfsoftware.com/"><img src="https://img.shields.io/badge/Created%20by%20Wolf%20on%20behalf%20of%20Wolf%20Software-blue?style=for-the-badge" /></a></p>
<p align="right"><a href="https://wolfsoftware.com/"><img src="https://img.shields.io/badge/Created%20by%20Wolf%20on%20behalf%20of%20Wolf%20Software-blue?style=for-the-badge" /></a></p>
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
description: 'The maximum major.minor version to include or "latest".'
required: false
default: 'latest'
max-versions:
description: 'The maximum number of versions to include.'
required: false
default: 0
include-prereleases:
description: 'Whether to include new version of Python that have no official releases.'
required: false
Expand Down Expand Up @@ -46,3 +50,4 @@ runs:
- ${{ inputs.highest-only }}
- ${{ inputs.remove-patch-version }}
- ${{ inputs.use-head }}
- ${{ inputs.max-versions }}
12 changes: 11 additions & 1 deletion entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def get_minimum_version_from_oel(language: str) -> str:
if release['eol'] is True:
continue

if release['eol'] is False:
if semver.parse(release['cycle']) < min_version:
min_version: str = semver.parse(release['cycle'])
continue

if (datetime.date.today() < datetime.date.fromisoformat(release['eol'])):
min_version = semver.parse(release['cycle'])

Expand Down Expand Up @@ -408,7 +413,8 @@ def main(language: str,
include_prereleases: str = 'false',
highest_only: str = 'false',
remove_patch_version: str = 'false',
use_head: str = 'false') -> None:
use_head: str = 'false',
max_versions: int = 0) -> None:
"""
Handle input from Docker container.
Expand Down Expand Up @@ -438,6 +444,7 @@ def main(language: str,
highest_only: bool = strtobool(highest_only)
remove_patch_version: bool = strtobool(remove_patch_version)
use_head: bool = strtobool(use_head)
max_versions: int = int(max_versions)

if remove_patch_version and include_prereleases:
print("You cannot combine include_prereleases with remove_patch")
Expand All @@ -464,6 +471,9 @@ def main(language: str,
if highest_only:
version_json = versions[-1]
else:
if max_versions > 0:
versions = versions[-max_versions:]

version_json = json.dumps(versions)

output_version_details(version_json)
Expand Down

0 comments on commit 6231958

Please sign in to comment.