-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add action to get pypi package latest versions
- Loading branch information
dhuangnm
authored and
dhuangnm
committed
Sep 19, 2024
1 parent
4515269
commit 34c6d43
Showing
1 changed file
with
32 additions
and
0 deletions.
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,32 @@ | ||
--- | ||
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 of package on PyPi | ||
value: ${{ steps.getpypi.outputs.versions }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- id: getpypi | ||
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}` | ||
echo "versions=${versions}" >> "$GITHUB_OUTPUT" | ||
shell: bash |