-
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 latest package versions on pypi (#28)
* 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
1 parent
7fdc658
commit 74adf41
Showing
2 changed files
with
36 additions
and
5 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,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 |
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