fix: bootstrap python on minimal runners

This commit is contained in:
袁震
2026-04-19 19:03:08 +08:00
parent 9d1e900c43
commit 6177eb3653
2 changed files with 52 additions and 8 deletions
+26 -4
View File
@@ -17,11 +17,32 @@ jobs:
fetch-depth: 0
github-server-url: https://git.halonice.com
- name: Check Python runtime
- name: Bootstrap Python runtime
shell: bash
run: |
set -euo pipefail
python3 --version
if command -v python3 >/dev/null 2>&1; then
py_bin="python3"
elif command -v python >/dev/null 2>&1; then
py_bin="python"
else
if command -v apt-get >/dev/null 2>&1; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache python3 py3-pip
elif command -v dnf >/dev/null 2>&1; then
dnf install -y python3 python3-pip
elif command -v yum >/dev/null 2>&1; then
yum install -y python3 python3-pip
else
echo "python is not available and no supported package manager was found" >&2
exit 1
fi
py_bin="python3"
fi
"${py_bin}" --version
echo "PYTHON_BIN=${py_bin}" >> "$GITHUB_ENV"
- name: Prepare config
shell: bash
@@ -44,9 +65,10 @@ jobs:
UPSTREAM_REF: ${{ vars.UPSTREAM_REF }}
run: |
UPSTREAM_REF="${UPSTREAM_REF:-master}"
PYTHON_BIN="${PYTHON_BIN:-python3}"
bash tools/sync_surge_full.sh
if [ -f configs/config.toml ]; then
python3 src/rulegen.py --config configs/config.toml
"${PYTHON_BIN}" src/rulegen.py --config configs/config.toml
else
python3 src/rulegen.py --config configs/config.json
"${PYTHON_BIN}" src/rulegen.py --config configs/config.json
fi
+26 -4
View File
@@ -22,11 +22,32 @@ jobs:
fetch-depth: 0
github-server-url: https://git.halonice.com
- name: Check Python runtime
- name: Bootstrap Python runtime
shell: bash
run: |
set -euo pipefail
python3 --version
if command -v python3 >/dev/null 2>&1; then
py_bin="python3"
elif command -v python >/dev/null 2>&1; then
py_bin="python"
else
if command -v apt-get >/dev/null 2>&1; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache python3 py3-pip
elif command -v dnf >/dev/null 2>&1; then
dnf install -y python3 python3-pip
elif command -v yum >/dev/null 2>&1; then
yum install -y python3 python3-pip
else
echo "python is not available and no supported package manager was found" >&2
exit 1
fi
py_bin="python3"
fi
"${py_bin}" --version
echo "PYTHON_BIN=${py_bin}" >> "$GITHUB_ENV"
- name: Prepare config
shell: bash
@@ -50,11 +71,12 @@ jobs:
run: |
set -euo pipefail
UPSTREAM_REF="${UPSTREAM_REF:-master}"
PYTHON_BIN="${PYTHON_BIN:-python3}"
bash tools/sync_surge_full.sh
if [ -f configs/config.toml ]; then
python3 src/rulegen.py --config configs/config.toml
"${PYTHON_BIN}" src/rulegen.py --config configs/config.toml
else
python3 src/rulegen.py --config configs/config.json
"${PYTHON_BIN}" src/rulegen.py --config configs/config.json
fi
- name: Commit and push builder updates