update ci #58
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: Build and Publish Wheels | |
on: | |
push: | |
branches: | |
- main | |
- "release/*" | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["38", "39", "310", "311"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Docker | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
lsb-release | |
sudo mkdir -p /etc/apt/keyrings | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
- name: Build the package in manylinux2014 docker container | |
run: | | |
docker run --rm \ | |
-v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 \ | |
/bin/bash -c ' | |
curl https://sh.rustup.rs -sSf | sh -s -- -y | |
source $HOME/.cargo/env | |
export PATH=$PATH:$HOME/.cargo/bin | |
rustc --version | |
for PYBIN in /opt/python/cp${PYTHON_VERSION}*/bin; do | |
"${PYBIN}/python" -m venv /venv | |
source /venv/bin/activate | |
pip install setuptools-rust==1.9.0 wheel | |
cd /io | |
python setup.py bdist_wheel | |
deactivate | |
done | |
' \ | |
--env PYTHON_VERSION=${{ matrix.python-version }} | |
- name: Rename wheels | |
run: | | |
sudo mkdir -p renamed_wheels | |
sudo chown -R $USER:$(id -gn) renamed_wheels | |
for whl in dist/*.whl; do | |
sudo mv "$whl" "renamed_wheels/$(basename "$whl" | sed 's/linux/manylinux2014/')" | |
done | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-manylinux2014-${{ matrix.python-version }} | |
path: renamed_wheels/* | |
build-macos: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Rust | |
run: brew install rust | |
- name: Install package dependencies | |
run: pip install setuptools-rust==1.9.0 | |
- name: Install build tools | |
run: pip install wheel | |
- name: Build the package | |
run: python setup.py sdist bdist_wheel | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-macos-${{ matrix.python-version }} | |
path: dist/* | |
build-windows: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Rust | |
run: rustup default stable | |
- name: Install package dependencies | |
run: pip install setuptools-rust==1.9.0 | |
- name: Install build tools | |
run: pip install wheel | |
- name: Build the package | |
run: python setup.py sdist bdist_wheel | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-windows-${{ matrix.python-version }} | |
path: dist/* | |
publish: | |
needs: [build-linux, build-macos, build-windows] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Linux artifacts for Python 3.8 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-manylinux2014-3.8 | |
path: dist/linux/3.8 | |
- name: Download Linux artifacts for Python 3.9 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-manylinux2014-3.9 | |
path: dist/linux/3.9 | |
- name: Download Linux artifacts for Python 3.10 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-manylinux2014-3.10 | |
path: dist/linux/3.10 | |
- name: Download Linux artifacts for Python 3.11 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-manylinux2014-3.11 | |
path: dist/linux/3.11 | |
- name: Download macOS artifacts for Python 3.8 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-macos-3.8 | |
path: dist/macos/3.8 | |
- name: Download macOS artifacts for Python 3.9 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-macos-3.9 | |
path: dist/macos/3.9 | |
- name: Download macOS artifacts for Python 3.10 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-macos-3.10 | |
path: dist/macos/3.10 | |
- name: Download macOS artifacts for Python 3.11 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-macos-3.11 | |
path: dist/macos/3.11 | |
- name: Download Windows artifacts for Python 3.8 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-windows-3.8 | |
path: dist/windows/3.8 | |
- name: Download Windows artifacts for Python 3.9 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-windows-3.9 | |
path: dist/windows/3.9 | |
- name: Download Windows artifacts for Python 3.10 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-windows-3.10 | |
path: dist/windows/3.10 | |
- name: Download Windows artifacts for Python 3.11 | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-windows-3.11 | |
path: dist/windows/3.11 | |
- name: Combine all artifacts | |
run: mkdir -p final_dist && find dist/ -type f -exec cp {} final_dist/ \; | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install twine | |
run: pip install twine | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: twine upload final_dist/* |