CI: use trusted publisher for PyPi publishing #559
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 Wheels | |
on: | |
push: | |
branches: | |
- main | |
- fix-wheel-build | |
- v* | |
release: | |
types: [created] | |
jobs: | |
build_wheels: | |
name: Build Wheels on ${{ matrix.os }}-${{ matrix.platform_id }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Run 32 and 64 bit version in parallel for Windows | |
- os: windows-2022 | |
platform_id: win_amd64 | |
architecture: x64 | |
- os: windows-2022 | |
platform_id: win32 | |
architecture: x86 | |
- os: macos-13 | |
platform_id: macosx_x86_64 | |
architecture: x64 | |
- os: macos-14 | |
platform_id: macosx_arm64 | |
architecture: arm64 | |
env: | |
CIBW_BUILD: cp39-${{ matrix.platform_id }} cp310-${{ matrix.platform_id }} cp311-${{ matrix.platform_id }} cp312-${{ matrix.platform_id }} cp313-${{ matrix.platform_id }} | |
CIBW_SKIP: pp* cp36* cp37* cp38* | |
CIBW_BEFORE_BUILD_MACOS: "python packing/download_pango_macos.py ${{ matrix.architecture }}" | |
CIBW_BEFORE_BUILD_WINDOWS: "python packing/download_dlls.py" | |
CIBW_ENVIRONMENT_WINDOWS: "PKG_CONFIG_PATH='C:\\cibw\\vendor\\lib\\pkgconfig'" | |
CIBW_ENVIRONMENT_MACOS: "PKG_CONFIG_PATH='/Users/runner/pangobuild/lib/pkgconfig'" | |
CIBW_TEST_REQUIRES: pytest pytest-cov | |
CIBW_TEST_COMMAND: "bash {project}/packing/test_wheels.sh {project}" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Path for pkg-config | |
if: runner.os == 'windows' | |
run: | | |
$env:Path = "C:\cibw\pkg-config\bin;C:\cibw\vendor\bin;$($env:PATH)" | |
echo "$env:Path" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Build wheels (Windows) | |
if: runner.os == 'windows' | |
shell: pwsh | |
run: | | |
Copy-Item packing/LICENSE.bin . | |
Rename-Item LICENSE.bin LICENSE.win32 | |
- name: Build wheels (Non-Windows) | |
if: runner.os != 'windows' | |
run: | | |
cp packing/LICENSE.bin . | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
PKG_CONFIG_PATH: "C:\\cibw\\vendor\\lib\\pkgconfig" | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
name: wheels-${{ runner.os }}-${{ matrix.platform_id }} | |
test_wheels_win: | |
name: Test wheels on Windows - ${{ matrix.platform_id }} (${{ matrix.python-version }}) | |
needs: [build_wheels] | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
architecture: [x64, x86] | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
include: [ | |
{platform_id: win_amd64, architecture: x64}, | |
{platform_id: win32, architecture: x86}, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.architecture }} | |
allow-prereleases: true | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheels-${{ runner.os }}-${{ matrix.platform_id }} | |
path: ~/wheelhouse | |
- name: Install test dependencies | |
run: | | |
pip install pytest pytest-cov | |
- name: Install wheels | |
run: | | |
pip install --no-index --find-links ~/wheelhouse ManimPango | |
- name: Run tests | |
shell: bash | |
run: | | |
bash packing/test_wheels.sh $(pwd) | |
test_wheels_mac: | |
name: Test wheels on macOS - ${{ matrix.platform_id }} (${{ matrix.python-version }}) | |
needs: [build_wheels] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
architecture: [x64, arm64] | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
include: [ | |
{platform_id: macosx_x86_64, architecture: x64, os: macos-13}, | |
{platform_id: macosx_arm64, architecture: arm64, os: macos-14}, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: ${{ matrix.architecture == 'arm64' && null || matrix.architecture }} | |
allow-prereleases: true | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheels-${{ runner.os }}-${{ matrix.platform_id }} | |
path: ~/wheelhouse | |
- name: Install test dependencies | |
run: | | |
pip install pytest pytest-cov | |
- name: Install wheels | |
run: | | |
pip install --no-index --find-links ~/wheelhouse ManimPango | |
- name: Run tests | |
shell: bash | |
run: | | |
bash packing/test_wheels.sh $(pwd) | |
build_sdist: | |
name: Source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
sudo apt install libcairo2-dev pkg-config python3-dev | |
sudo apt-get install libpango1.0-dev | |
python -m pip install --upgrade build | |
- name: Build sdist | |
run: python -m build --sdist | |
- name: Test sdist | |
run: | | |
python -m pip install dist/*.tar.gz | |
- name: Store artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
path: dist/*.tar.gz | |
name: manimpango-src | |
publish: | |
needs: [test_wheels_mac, test_wheels_win, build_sdist] | |
name: Upload wheels to PyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: release | |
url: https://pypi.org/p/ManimPango | |
permissions: | |
id-token: write | |
contents: write | |
if: github.event_name== 'release' | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
path: downloads/ | |
- name: Move files to dist | |
run: | | |
mkdir -p dist/ | |
find downloads/ -name \*.whl -exec cp {} dist \; | |
find downloads/ -name \*.tar.gz -exec cp {} dist \; | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
fail_on_unmatched_files: false | |
files: | | |
dist/*.whl | |
dist/*.tar.gz | |
success: | |
needs: [test_wheels_win, test_wheels_mac] | |
runs-on: ubuntu-latest | |
name: Building and testing of wheels success | |
steps: | |
- name: Success | |
run: echo "Building and testing of wheels success" |