Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ description: Installs project dependencies
runs:
using: composite
steps:
- name: Find latest Python supported by Red-DiscordBot
id: find_pyver
shell: bash
run: |
PYVER=$(bash "$GITHUB_WORKSPACE/.github/find_latest_red_pyver.sh")
echo "python-version=$PYVER" >> "$GITHUB_OUTPUT"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: ${{ steps.find_pyver.outputs.python-version }}
- name: Install base dependencies
shell: bash
run: pip install --quiet --upgrade --requirement requirements.txt
- name: Install CI dependencies
- name: Install CI & cog dependencies
shell: bash
run: pip install --quiet --upgrade --requirement requirements-dev.txt
- name: Install cog dependencies
shell: bash
run: |
python3 .github/actions/setup/compile_requirements.py
pip install --quiet --upgrade --requirement requirements-cogs.txt
28 changes: 0 additions & 28 deletions .github/actions/setup/compile_requirements.py

This file was deleted.

29 changes: 29 additions & 0 deletions .github/find_latest_red_pyver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail

PACKAGE="Red-DiscordBot"

# Fetch requires_python string, e.g. ">=3.9,<3.13"
REQUIRES=$(curl -s "https://pypi.org/pypi/${PACKAGE}/json" | jq -r '.info.requires_python')

# Extract lower and upper bounds
LOWER=$(grep -oP '(?<=\>=)[0-9]+\.[0-9]+' <<<"$REQUIRES" || true)
UPPER=$(grep -oP '(?<=\<)[0-9]+\.[0-9]+' <<<"$REQUIRES" | head -n1 || true)

# Get all active Python versions from endoflife.date API
VERSIONS=$(curl -s https://endoflife.date/api/python.json | jq -r '.[].latest' | cut -d. -f1,2 | sort -Vu)

# Filter by lower/upper bounds
SUPPORTED=$(echo "$VERSIONS" | while read v; do
if [[ -n "$LOWER" && "$(printf '%s\n' "$v" "$LOWER" | sort -V | head -n1)" != "$LOWER" ]]; then
continue
fi
if [[ -n "$UPPER" && "$(printf '%s\n' "$v" "$UPPER" | sort -V | head -n1)" == "$UPPER" ]]; then
continue
fi
echo "$v"
done)

LATEST=$(echo "$SUPPORTED" | sort -V | tail -n1)

echo "$LATEST"
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
- name: Checkout the repository at the current branch
uses: actions/checkout@v4
- name: Install dependencies
id: setup_deps
uses: ./.github/actions/setup
- uses: jakebailey/pyright-action@v2
with:
python-version: "3.11"
python-version: ${{ steps.setup_deps.outputs.python-version }}

check-json:
runs-on: ubuntu-latest
Expand Down
Loading