chore: Update Python version and krunner dependencies (#7) #104
This file contains 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: default | |
on: [push] | |
jobs: | |
sdist: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pip setuptools wheel | |
- name: Build sdist | |
run: | | |
python setup.py sdist | |
ls -lh dist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-src | |
path: dist | |
bdist_wheel: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04] | |
pyver: [cp312-cp312] | |
arch: [x86_64, aarch64] | |
env: | |
py: /opt/python/${{ matrix.pyver }}/bin/python | |
img: quay.io/pypa/manylinux2014_${{ matrix.arch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
- name: Show available platforms | |
run: echo ${{ steps.qemu.outputs.platforms }} | |
- name: Install dependencies | |
run: | | |
sudo apt install -y xz-utils | |
docker pull ${{ env.img }} | |
# for host env | |
python -m pip install -U pip setuptools wheel | |
python -m pip install -U -r requirements/build.txt | |
python -m pip install -U -e . | |
# for arch-specific env | |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws ${{ env.img }} \ | |
${{ env.py }} -m pip install -U pip setuptools wheel | |
- name: Build wheel | |
run: | | |
python scripts/build.py --arch ${{ matrix.arch }} | |
sed -i 's/ARCH/${{ matrix.arch }}/g' MANIFEST.in | |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws ${{ env.img }} \ | |
${{ env.py }} setup.py bdist_wheel | |
PKGVER=$(python -c 'from ai.backend.krunner.static_gnu import __version__; print(__version__, end="")') | |
GLIBC_PTAG=manylinux2014_${{ matrix.arch }} # to allow installing the krunner wheel when running Backend.AI on manylinux | |
MUSL_PTAG=musllinux_1_1_${{ matrix.arch }} # to allow installing the krunner wheel when running Backend.AI on musllinux | |
case "${{ matrix.arch }}" in # to allow installing the krunner wheel when running Backend.AI on macOS | |
"aarch64") | |
MACOS_PTAG=macosx_11_0_arm64 ;; | |
*) | |
MACOS_PTAG=macosx_11_0_${{ matrix.arch }} ;; | |
esac | |
sudo mv dist/backend.ai_krunner_static_gnu-${PKGVER}-*.whl \ | |
dist/backend.ai_krunner_static_gnu-${PKGVER}-py3-none-${GLIBC_PTAG}.${MUSL_PTAG}.${MACOS_PTAG}.whl | |
ls -lh dist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-${{ matrix.os }}-${{ matrix.pyver }}-${{ matrix.arch }} | |
path: dist | |
deploy-to-pypi: | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
needs: [sdist, bdist_wheel] | |
environment: | |
name: deploy-to-pypi | |
url: https://pypi.org/p/backend.ai-krunner-static-gnu | |
permissions: | |
id-token: write | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Download distributions | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: dist-* | |
merge-multiple: true | |
path: dist | |
- name: >- | |
Publish 🐍📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |