Skip to content

Build and Publish Wheels #48

Build and Publish Wheels

Build and Publish Wheels #48

Workflow file for this run

name: Build and Publish Wheels
on: [workflow_dispatch]
env:
USING_PYTHON_VERSION: '3.13.9'
jobs:
prepare:
runs-on: tenki-standard-autoscale
outputs:
LATEST_TDLIB_VERSION: ${{ steps.vars.outputs.LATEST_TDLIB_VERSION }}
LATEST_TDLIB_COMMIT_HASH: ${{ steps.vars.outputs.LATEST_TDLIB_COMMIT_HASH }}
PYPI_RELEASE_VERSION: ${{ steps.vars.outputs.PYPI_RELEASE_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install dependencies
run: python -m pip install --upgrade packaging requests
- name: Fetch TDLib version and commit hash
id: vars
run: |
LATEST_TDLIB_COMMIT_HASH=$(curl -s "https://api.github.com/repos/tdlib/td/commits/master" | grep -oP '"sha": "\K[^"]+' | head -1)
LATEST_TDLIB_VERSION=$(curl -s "https://raw.githubusercontent.com/tdlib/td/$LATEST_TDLIB_COMMIT_HASH/CMakeLists.txt" | grep -oP 'project\(TDLib VERSION \K[0-9\.]+')
PYPI_RELEASE_VERSION=$(python next_version.py $LATEST_TDLIB_VERSION)
echo "LATEST_TDLIB_COMMIT_HASH=$LATEST_TDLIB_COMMIT_HASH" >> $GITHUB_OUTPUT
echo "LATEST_TDLIB_VERSION=$LATEST_TDLIB_VERSION" >> $GITHUB_OUTPUT
echo "PYPI_RELEASE_VERSION=$PYPI_RELEASE_VERSION" >> $GITHUB_OUTPUT
- name: Apply version changes
run: |
LATEST_TDLIB_VERSION=${{ steps.vars.outputs.LATEST_TDLIB_VERSION }}
PYPI_RELEASE_VERSION=${{ steps.vars.outputs.PYPI_RELEASE_VERSION }}
sed -i -r "s/^__version__ = \".*\"/__version__ = \"$PYPI_RELEASE_VERSION\"/" tdjson/_version.py
sed -i -r "s|(https://img.shields.io/badge/TDLib-v)[0-9\.]+(-blue)|\\1$LATEST_TDLIB_VERSION\\2|" README.md
- name: Upload updated files
uses: actions/upload-artifact@v4
with:
name: updated-files
path: |
tdjson/_version.py
README.md
linux-build:
needs: prepare
strategy:
matrix:
runner: [tenki-standard-autoscale, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install dependencies
run: python -m pip install --upgrade scikit-build-core nanobind build ninja cibuildwheel auditwheel
- name: Build wheels
run: |
mkdir -p ./wheelhouse
python -m cibuildwheel . --output-dir ./wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.runner }}
path: ./wheelhouse/*.whl
windows-build:
needs: prepare
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install Python dependencies
shell: bash
run: python -m pip install --upgrade cibuildwheel
- name: Build TDLib
shell: bash
run: |
git clone --depth 1 https://github.com/tdlib/td.git
cd td
cat << EOF > vcpkg.json
{
"dependencies": [ "gperf", "openssl", "zlib" ],
"builtin-baseline": "afb2279ad78a7c29b5293d989b9a1a2ca00000cf",
"overrides": [
{ "name": "openssl", "version": "1.1.1m" }
]
}
EOF
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
cd ..
rm -rf build
mkdir build
cd build
cmake -A x64 -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --target install --config Release -j3
cd ..
cd ..
ls -l td/tdlib
echo "${{ github.workspace }}/td/tdlib/bin" >> $GITHUB_PATH
- name: Build wheels
shell: bash
env:
CMAKE_PREFIX_PATH: ${{ github.workspace }}/td/tdlib
run: |
mkdir -p ./wheelhouse
python -m cibuildwheel . --output-dir ./wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: ./wheelhouse/*.whl
publish:
needs: [prepare, linux-build, windows-build]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: ./dist
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Commit updated files
uses: EndBug/add-and-commit@v9
with:
message: "Update TDLib to ${{ needs.prepare.outputs.LATEST_TDLIB_VERSION }} (tdlib/td@${{ needs.prepare.outputs.LATEST_TDLIB_COMMIT_HASH }})"
add: '["README.md", "tdjson/_version.py"]'
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com