Update Model Lists #60
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: Update Model Lists | |
| on: | |
| schedule: | |
| # Run daily at 6 AM UTC | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: write | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Run model updater | |
| run: cargo run --bin update-models --features updater | |
| - name: Run tests | |
| run: cargo test | |
| - name: Validate generated models | |
| id: validate | |
| run: | | |
| # Check that model arrays are not empty | |
| VISION_COUNT=$(grep -c '"' src/generated.rs | head -1 || echo "0") | |
| if [ "$VISION_COUNT" -lt 10 ]; then | |
| echo "::error::Generated file appears to have too few models (found ~$VISION_COUNT). Aborting to prevent publishing empty package." | |
| exit 1 | |
| fi | |
| echo "Validation passed: found approximately $VISION_COUNT model entries" | |
| - name: Regression check | |
| run: | | |
| OLD_COUNT=$(git show HEAD:src/generated.rs | grep -c '"' || echo "0") | |
| NEW_COUNT=$(grep -c '"' src/generated.rs || echo "0") | |
| THRESHOLD=$((OLD_COUNT * 80 / 100)) | |
| if [ "$NEW_COUNT" -lt "$THRESHOLD" ]; then | |
| echo "::error::Model count regression: $OLD_COUNT -> $NEW_COUNT" | |
| exit 1 | |
| fi | |
| echo "Regression check passed: $OLD_COUNT -> $NEW_COUNT" | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet src/generated.rs; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "new_models=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| # Check if any new model entries were added (added lines containing quoted strings) | |
| NEW_ENTRIES=$(git diff src/generated.rs | grep '^+.*"' | grep -v '^+++' | wc -l | tr -d ' ') | |
| if [ "$NEW_ENTRIES" -gt 0 ]; then | |
| echo "new_models=true" >> $GITHUB_OUTPUT | |
| echo "Found $NEW_ENTRIES new model entries" | |
| else | |
| echo "new_models=false" >> $GITHUB_OUTPUT | |
| echo "No new model entries (only removals or metadata changes)" | |
| fi | |
| fi | |
| - name: Commit and push changes | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add src/generated.rs | |
| git commit -m "chore: update model lists from OpenRouter, LiteLLM, and Arena" | |
| git push | |
| - name: Bump version and publish | |
| if: steps.changes.outputs.new_models == 'true' | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: | | |
| # Bump patch version | |
| CURRENT_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') | |
| MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1) | |
| MINOR=$(echo $CURRENT_VERSION | cut -d. -f2) | |
| PATCH=$(echo $CURRENT_VERSION | cut -d. -f3) | |
| NEW_PATCH=$((PATCH + 1)) | |
| NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" | |
| # Update Cargo.toml | |
| sed -i "s/^version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" Cargo.toml | |
| # Commit version bump | |
| git add Cargo.toml | |
| git commit -m "chore: bump version to $NEW_VERSION" | |
| git push | |
| # Create tag | |
| git tag "v$NEW_VERSION" | |
| git push origin "v$NEW_VERSION" | |
| # Publish to crates.io | |
| cargo publish --allow-dirty |