-
Notifications
You must be signed in to change notification settings - Fork 543
134 lines (127 loc) · 5.13 KB
/
upload_pypi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# 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