69 lines
2.4 KiB
YAML
69 lines
2.4 KiB
YAML
name: CI | Update runpod package version
|
|
|
|
on:
|
|
repository_dispatch:
|
|
types: [python-package-release]
|
|
|
|
push:
|
|
branches: ["main"]
|
|
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
check_dep:
|
|
runs-on: ubuntu-latest
|
|
name: Check python requirements file and update
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check for new package version and update
|
|
run: |
|
|
echo "Fetching current runpod version from requirements.txt..."
|
|
|
|
# Match runpod with any version specifier or no specifier at all
|
|
current_version=$(grep -oP '^runpod([~>=!<]{1,2}\K[\d.]+)?' ./builder/requirements.txt | grep -oP '[\d.]+' || echo "")
|
|
echo "Current version: ${current_version:-unset}"
|
|
|
|
echo "Fetching latest runpod version from PyPI..."
|
|
new_version=$(curl -sf https://pypi.org/pypi/runpod/json | jq -r .info.version)
|
|
echo "NEW_VERSION_ENV=$new_version" >> $GITHUB_ENV
|
|
echo "New version: $new_version"
|
|
|
|
if [ -z "$new_version" ]; then
|
|
echo "ERROR: Failed to fetch new version from PyPI."
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$current_version" ]; then
|
|
echo "No version pin found — pinning to $new_version."
|
|
else
|
|
current_major_minor=$(echo "$current_version" | cut -d. -f1,2)
|
|
new_major_minor=$(echo "$new_version" | cut -d. -f1,2)
|
|
echo "Current major.minor: $current_major_minor New major.minor: $new_major_minor"
|
|
|
|
if [ "$current_major_minor" = "$new_major_minor" ]; then
|
|
echo "No update needed. New version ($new_version) is within ~= $current_major_minor range."
|
|
exit 0
|
|
fi
|
|
|
|
echo "New major/minor detected ($new_major_minor). Updating requirements.txt..."
|
|
fi
|
|
|
|
# Replace any `runpod`, `runpod==x`, `runpod~=x`, etc. with pinned version
|
|
sed -i "s|^runpod.*|runpod~=$new_version|" ./builder/requirements.txt
|
|
echo "requirements.txt updated."
|
|
|
|
- name: Create Pull Request
|
|
uses: peter-evans/create-pull-request@v7
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
commit-message: "chore: update runpod to ${{ env.NEW_VERSION_ENV }}"
|
|
title: "chore: update runpod to ${{ env.NEW_VERSION_ENV }}"
|
|
body: The `runpod` package has been updated to `${{ env.NEW_VERSION_ENV }}`.
|
|
branch: runpod-package-update
|