-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Checks whether a version is a prerelease | ||
description: Checks whether a version is prerelease according to PEP440. | ||
inputs: | ||
version: | ||
description: Version number to check. | ||
required: true | ||
outputs: | ||
prerelease: | ||
description: Whether the version number is a prerelease. | ||
value: ${{ steps.check-prerelease.outputs.PRERELEASE }} | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install packaging | ||
run: pip install packaging | ||
shell: bash | ||
|
||
- name: Check if prerelease | ||
id: check-prerelease | ||
run: ./.github/actions/check-prerelease/check_prerelease.py ${{ inputs.version }} >> "$GITHUB_OUTPUT" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
|
||
from packaging.version import parse as parse_version | ||
|
||
if __name__ == "__main__": | ||
arg_parser = argparse.ArgumentParser( | ||
description="Check whether a version is a prerelease according to PEP440." | ||
) | ||
arg_parser.add_argument("version") | ||
args = arg_parser.parse_args() | ||
|
||
if parse_version(args.version).is_prerelease: | ||
print("PRERELEASE=true") | ||
else: | ||
print("PRERELEASE=false") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Get latest release | ||
description: Gets the latest (non-prerelease) version of a PyPI package. | ||
inputs: | ||
package: | ||
description: Name of the the package. | ||
required: true | ||
outputs: | ||
latest_version: | ||
description: Latest version of the package. | ||
value: ${{ steps.get-latest.outputs.VERSION }} | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install packaging | ||
run: pip install packaging requests | ||
shell: bash | ||
|
||
- name: Get latest version | ||
id: get-latest | ||
run: ./.github/actions/get-latest-release/get_latest_release.py ${{ inputs.package }} >> "$GITHUB_OUTPUT" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
|
||
import requests | ||
from packaging.version import parse as parse_version | ||
|
||
if __name__ == "__main__": | ||
arg_parser = argparse.ArgumentParser( | ||
description="Get the latest non-prerelease version of a package according to PEP440." | ||
) | ||
arg_parser.add_argument("package") | ||
args = arg_parser.parse_args() | ||
|
||
r = requests.get( | ||
f"https://pypi.org/simple/{args.package}", | ||
headers={"Accept": "application/vnd.pypi.simple.v1+json"}, | ||
timeout=30, | ||
) | ||
r.raise_for_status() | ||
versions = [parse_version(v) for v in r.json().get("versions", [])] | ||
latest = max(v for v in versions if not v.is_prerelease) | ||
if latest: | ||
print(f"VERSION={latest}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters