Skip to content

Upload component to Python Package Index #39

Upload component to Python Package Index

Upload component to Python Package Index #39

Workflow file for this run

# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
name: Upload component to Python Package Index
on:
workflow_dispatch:
inputs:
release:
type: boolean
default: false
required: false
description: "Release? If false, publish to test.pypi.org, if true, publish to pypi.org"
jobs:
build_binaries:
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
strategy:
matrix:
platform:
- runner: windows-latest
target: x64
container: auto
- runner: macos-13
target: x86_64
container: auto
- runner: macos-14
target: aarch64
container: auto
- runner: ubuntu-latest
target: x86_64
container: auto
- runner: ubuntu-latest
target: aarch64
container: "ghcr.io/slint-ui/slint/aarch64-unknown-linux-gnu"
- runner: ubuntu-latest
target: armv7
container: "ghcr.io/slint-ui/slint/armv7-unknown-linux-gnueabihf"
runs-on: ${{ matrix.platform.runner }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-linux-dependencies
if: runner.os == 'Linux'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Prepare feature config for binaries
working-directory: api/python
shell: bash
run: |
perl -pi -e 's,^default =.*,,' Cargo.toml
perl -pi -e 's,# binaries:,,' Cargo.toml
echo "New defaults:"
grep "^\s*default =" Cargo.toml
- name: Build a binary wheel
uses: PyO3/maturin-action@v1
with:
working-directory: api/python
target: ${{ matrix.platform.target }}
args: --release --out wheelhouse --find-interpreter
container: ${{ matrix.platform.container }}
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.platform.runner }}-${{ strategy.job-index }}
path: api/python/wheelhouse/*.whl
build_source_package:
name: Build source package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare feature config for binaries
working-directory: api/python
shell: bash
run: |
perl -pi -e 's,^default =.*,,' Cargo.toml
perl -pi -e 's,# binaries:,,' Cargo.toml
echo "New defaults:"
grep "^\s*default =" Cargo.toml
- name: Build source package
uses: PyO3/maturin-action@v1
with:
working-directory: api/python
command: sdist
args: --out dist
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions-source
path: api/python/dist/*.tar.gz
publish-to-test-pypi:
if: ${{ github.event.inputs.release != 'true' }}
name: >-
Publish Python 🐍 distribution 📦 to Test PyPI
needs: [build_binaries, build_source_package]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/slint
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
path: dist
merge-multiple: true
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
if: ${{ github.event.inputs.release == 'true' }}
name: >-
Publish Python 🐍 distribution 📦 to PyPI
needs: [build_binaries, build_source_package]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/p/slint
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
pattern: python-package-distributions-*
path: dist
merge-multiple: true
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1