Skip to content

Commit 3f2eb63

Browse files
committed
Add ability to exclude versions from build
1 parent 497ba95 commit 3f2eb63

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ inputs:
4545
required: true
4646
default: '10'
4747

48+
exclude_versions:
49+
description: 'A comma separated list of versions to exclude.'
50+
required: true
51+
default: ''
52+
4853
include_prereleases:
4954
description: 'If set to true prereleases (alpha, beta, rc) will also be built.'
5055
required: true
@@ -68,6 +73,7 @@ runs:
6873
env:
6974
MAX_VERSIONS: ${{ inputs.max_versions }}
7075
INCLUDE_PRERELEASE: ${{ inputs.include_prereleases }}
76+
EXCLUDE_VERSIONS: ${{ inputs.exclude_versions }}
7177

7278
- name: Update Python Versions
7379
shell: bash
@@ -90,6 +96,7 @@ runs:
9096
REPOSITORY: ${{ inputs.repository }}
9197
INCLUDE_PRERELEASE: ${{ inputs.include_prereleases }}
9298
BUILDER_WORKFLOW_PATH: ${{ inputs.action_path }}
99+
EXCLUDE_VERSIONS: ${{ inputs.exclude_versions }}
93100

94101
- name: "Push"
95102
shell: bash

scripts/latest_versions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
PACKAGE = sys.argv[1]
88
MAX_VERSIONS = sys.argv[2] if len(sys.argv) > 2 else 10
9+
EXCLUDE_VERSIONS=os.environ.get("EXCLUDE_VERSIONS", "").split(",")
910

1011
# Load PyPI website for the package
1112
fp = urllib.request.urlopen(f"https://pypi.org/simple/{PACKAGE}/")
@@ -15,10 +16,10 @@
1516
# Pick a regex- either include prerelease versions or not
1617
if os.environ.get("INCLUDE_PRERELEASE", False) == 'true':
1718
version_regex = re.compile(r'-(\d+\.\d+\.\d+(a|b|rc)?\d?).+[\.whl|\.tar\.gz]')
18-
versions = [x[0] for x in version_regex.findall(html_string)]
19+
versions = [x[0] for x in version_regex.findall(html_string) if x[0] not in EXCLUDE_VERSIONS]
1920
else:
2021
version_regex = re.compile(r'-(\d+\.\d+\.\d+).+[\.whl|\.tar\.gz]')
21-
versions = version_regex.findall(html_string)
22+
versions = [x for x in version_regex.findall(html_string) if x not in EXCLUDE_VERSIONS]
2223

2324
unique_versions = list(dict.fromkeys(versions))
2425

0 commit comments

Comments
 (0)