Merge pull request #35 from runpod-workers/runpod-package-update #102
This file contains hidden or 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
| name: CI | Update runpod package version | |
| on: | |
| repository_dispatch: | |
| types: [python-package-release] | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| jobs: | |
| check_dep: | |
| runs-on: ubuntu-latest | |
| name: Check python requirements file and update | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Check for new package version and update | |
| run: | | |
| echo "Fetching the current runpod version from requirements.txt..." | |
| # Get current version (supports '>=' versioning) | |
| current_version=$(grep -oP 'runpod>=\K[^ ]+' ./builder/requirements.txt) | |
| echo "Current version: $current_version" | |
| # Get new version from PyPI | |
| new_version=$(curl -s 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 the new version from PyPI." | |
| exit 1 | |
| fi | |
| if [ -z "$current_version" ]; then | |
| echo "ERROR: Failed to extract current version from requirements.txt." | |
| exit 1 | |
| fi | |
| # Compare versions using sort -V (version sort) | |
| if [ "$current_version" = "$new_version" ]; then | |
| echo "No update needed. Already at version $new_version." | |
| exit 0 | |
| fi | |
| # Check if new version is actually newer | |
| newer_version=$(printf "%s\n%s" "$current_version" "$new_version" | sort -V | tail -n1) | |
| if [ "$newer_version" = "$current_version" ]; then | |
| echo "No update needed. Current version ($current_version) is already >= new version ($new_version)." | |
| exit 0 | |
| fi | |
| echo "New version detected ($new_version > $current_version). Updating runpod version..." | |
| # Update requirements.txt with the new version while keeping '>=' | |
| sed -i "s/runpod>=.*/runpod>=$new_version/" ./builder/requirements.txt | |
| echo "requirements.txt has been updated." | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: Update runpod package version | |
| title: Update runpod package version | |
| body: The package version has been updated to ${{ env.NEW_VERSION_ENV }} | |
| branch: runpod-package-update |