- _corebuild.musl_platform_tag(): на musl (Alpine/HA OS) bdist_wheel выпускает py3-none-musllinux_X_Y_<arch> вместо linux_<arch> — иначе pip ставит glibc-сборку и dlopen падает на ld-linux-x86-64.so.2 - shared-библиотека линкуется со -static-libstdc++ -static-libgcc (gcc): NEEDED только libm/libc (проверено readelf), меньше зависимостей у HA OS - Gitea Actions: job build-musllinux (container python:3.12-alpine) собирает и публикует musl-wheel; build-glibc — как раньше; общий scripts/publish-gitea-pypi.sh с пропуском уже загруженных файлов - тесты musl_platform_tag; RELEASE_HA §1.1-1.4 (выбор wheel, переустановка на HA OS, ручная сборка musllinux без container:); README troubleshooting
136 lines
5.4 KiB
YAML
136 lines
5.4 KiB
YAML
# Сборка и публикация pyfglair в PyPI-реестр пакетов Gitea.
|
|
# Запуск: Actions → Publish pyfglair → Run workflow (workflow_dispatch).
|
|
#
|
|
# Собираются ДВА wheel (одинаковая версия):
|
|
# * linux_x86_64 — glibc (HA Supervised/Core на Debian/Ubuntu);
|
|
# * musllinux_X_Y — musl (HA OS: Alpine-контейнеры); собирается в
|
|
# контейнере python:3.12-alpine. Если runner не поддерживает
|
|
# `container:` — job build-musllinux упадёт на apk; в этом случае
|
|
# musllinux-wheel соберите вручную (см. docs/RELEASE_HA.md §1.4).
|
|
#
|
|
# Авторизация: встроенный job-токен при `permissions: packages: write`
|
|
# (Gitea ≥ 1.27) либо PAT write:package в секрете PYPI_TOKEN.
|
|
# Секрет PYPI_USER — имя пользователя к PAT; имена секретов не могут
|
|
# начинаться с GITEA_ (префикс зарезервирован).
|
|
name: Publish pyfglair
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
bundled_mbedtls:
|
|
description: "1 — встроить mbedtls, 0 — использовать системный"
|
|
required: false
|
|
default: "1"
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
build-glibc:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Toolchain
|
|
run: |
|
|
if ! command -v cmake >/dev/null || ! command -v ninja >/dev/null \
|
|
|| ! command -v g++ >/dev/null; then
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends cmake ninja-build g++
|
|
fi
|
|
if [ "${{ inputs.bundled_mbedtls }}" = "0" ]; then
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends libmbedtls-dev
|
|
fi
|
|
cmake --version | head -1
|
|
g++ --version | head -1
|
|
|
|
- name: Build wheel + sdist (glibc)
|
|
env:
|
|
BUNDLED: ${{ inputs.bundled_mbedtls }}
|
|
run: |
|
|
if [ "$BUNDLED" = "0" ]; then
|
|
export FGL_BUNDLED_MBEDTLS=0
|
|
else
|
|
export FGL_BUNDLED_MBEDTLS=1
|
|
fi
|
|
pip install --upgrade build
|
|
python -m build
|
|
ls -l dist
|
|
|
|
# Запуск из каталога без исходников: иначе python подхватывает
|
|
# ./pyfglair (без собранного .so) вместо установленного wheel.
|
|
- name: Smoke test wheel (glibc)
|
|
run: |
|
|
python -m venv /tmp/wheeltest
|
|
WHEEL="$(pwd)/dist"
|
|
/tmp/wheeltest/bin/pip install --quiet "$WHEEL"/*.whl
|
|
cd /tmp
|
|
/tmp/wheeltest/bin/python -P -c "import pyfglair.session as s; print('pyfglair(glibc):', s.__file__)"
|
|
/tmp/wheeltest/bin/python -P -c "from pyfglair import Template, Prop, convert_to_display; assert convert_to_display(Template.A, Prop.DISPLAY_TEMPERATURE, 7000) == 200"
|
|
|
|
- name: Publish glibc wheel + sdist
|
|
env:
|
|
SERVER: ${{ github.server_url }}
|
|
OWNER: ${{ github.repository_owner }}
|
|
TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
GITEA_JOB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
PYPI_USER: ${{ secrets.PYPI_USER }}
|
|
run: bash scripts/publish-gitea-pypi.sh
|
|
|
|
build-musllinux:
|
|
runs-on: ubuntu-latest
|
|
container: python:3.12-alpine
|
|
steps:
|
|
- name: Build musllinux wheel
|
|
env:
|
|
BUNDLED: ${{ inputs.bundled_mbedtls }}
|
|
REPO_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
|
SHA: ${{ github.sha }}
|
|
run: |
|
|
apk add --no-cache git cmake ninja g++ make curl libstdc++-dev
|
|
if [ -z "$REPO_URL" ] || [ "$REPO_URL" = "/.git" ]; then
|
|
echo "::error::Пустой github.server_url/repository — задайте контексты или соберите musllinux вручную (docs/RELEASE_HA.md §1.4)"
|
|
exit 1
|
|
fi
|
|
git clone --depth 1 "$REPO_URL" /src
|
|
cd /src
|
|
if [ -n "$SHA" ]; then
|
|
git fetch --depth 1 origin "$SHA"
|
|
git checkout --detach FETCH_HEAD
|
|
fi
|
|
if [ "$BUNDLED" = "0" ]; then
|
|
export FGL_BUNDLED_MBEDTLS=0
|
|
else
|
|
export FGL_BUNDLED_MBEDTLS=1
|
|
fi
|
|
pip install --upgrade build
|
|
python -m build --wheel
|
|
ls -l dist
|
|
|
|
- name: Smoke test wheel (musl)
|
|
run: |
|
|
cd /src
|
|
python -m venv /tmp/wheeltest
|
|
/tmp/wheeltest/bin/pip install --quiet "$(pwd)"/dist/*.whl
|
|
cd /tmp
|
|
/tmp/wheeltest/bin/python -P -c "import pyfglair.session as s; print('pyfglair(musl):', s.__file__)"
|
|
/tmp/wheeltest/bin/python -P -c "from pyfglair import Template, Prop, convert_to_display; assert convert_to_display(Template.A, Prop.DISPLAY_TEMPERATURE, 7000) == 200"
|
|
|
|
- name: Publish musllinux wheel
|
|
env:
|
|
SERVER: ${{ github.server_url }}
|
|
OWNER: ${{ github.repository_owner }}
|
|
TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
GITEA_JOB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
PYPI_USER: ${{ secrets.PYPI_USER }}
|
|
DIST_DIR: /src/dist
|
|
run: cd /src && bash scripts/publish-gitea-pypi.sh
|