Skip to content

Commit

Permalink
Add action to get latest package versions on pypi (#28)
Browse files Browse the repository at this point in the history
* add action to get pypi package latest versions

* debugging

* debug

* clean up and minor fix

* fix error

* clean up

---------

Co-authored-by: dhuangnm <[email protected]>
Co-authored-by: dhuangnm <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 7fdc658 commit 74adf41
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
36 changes: 36 additions & 0 deletions actions/get-pypi-latest-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: get package latest versions on PyPi
description: get package latest versions on PyPi

inputs:
package_name:
description: name of the package
required: true
num_of_latest:
description: number of latest versions
default: 1

outputs:
versions:
description: return latest versions (separated by ;) of package on PyPi
value: ${{ steps.getpypi.outputs.versions }}

runs:
using: composite
steps:
- name: get package versions from pypi
id: getpypi
shell: bash
run: |-
URL="https://pypi.org/project/${{ inputs.package_name }}/#history"
curl --header 'Accept: application/vnd.pypi.simple.v1+json' ${URL} > history.log
all=`cat history.log | grep 'release__card' | sed 's/.*project\///g' | cut -d'/' -f2`
latest=${{ inputs.num_of_latest }}
if [[ -z "${{ inputs.num_of_latest }}" ]]; then
latest=1
fi
versions=`echo "${all}" | head -${latest} | tr '\n' ';'`
echo "versions=${versions}" >> "$GITHUB_OUTPUT"
if [ -z "${versions}" ]; then
exit 1
fi
5 changes: 0 additions & 5 deletions actions/verify-python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ inputs:
description: version of python to verify, e.g. 3.10
required: true

outputs:
version:
description: result from 'python --version'
value: ${{ steps.env_python.outputs.version }}

runs:
using: composite
steps:
Expand Down

0 comments on commit 74adf41

Please sign in to comment.