-
Notifications
You must be signed in to change notification settings - Fork 23
178 lines (162 loc) · 5.67 KB
/
python_publish.yml
File metadata and controls
178 lines (162 loc) · 5.67 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Publish Python SDK to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
test_publish:
description: "Publish to Test-PyPI only"
required: false
default: true
type: boolean
permissions:
contents: read
jobs:
wheels:
if: (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'iota-python-sdk')) || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- name: linux
target: x86_64
runner: ubuntu-latest
container: 2_28
- name: linux
target: i686
runner: ubuntu-latest
container: 2_28
- name: linux
target: aarch64
runner: ubuntu-latest
container: 2_28
- name: linux
target: armv7l
runner: ubuntu-latest
container: 2_28
- name: linux
target: ppc64le
runner: ubuntu-latest
container: 2_28
- name: musllinux
target: x86_64
runner: ubuntu-latest
container: musllinux_1_2
- name: musllinux
target: x86
runner: ubuntu-latest
container: musllinux_1_2
- name: musllinux
target: aarch64
runner: ubuntu-latest
container: musllinux_1_2
- name: musllinux
target: armv7
runner: ubuntu-latest
container: musllinux_1_2
- name: macos
target: x86_64
runner: macos-latest
container: ""
- name: macos
target: aarch64
runner: macos-latest
container: ""
- name: windows
target: x64
runner: windows-latest
container: ""
- name: windows
target: x86
runner: windows-latest
container: ""
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.event.release.tag_name || github.ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@0f44b27771c32bda9f458f75a1e241b09791b331
with:
toolchain: stable
- name: Install `uniffi-bindgen` for maturin
run: cargo install --path crates/iota-sdk-ffi --bin uniffi-bindgen
- name: Install Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: 3.9
- name: Build ${{ matrix.platform.name }}-${{ matrix.platform.target }} wheel
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
with:
target: ${{ matrix.platform.target }}
args: --release --find-interpreter
working-directory: bindings/python/src
manylinux: ${{ matrix.platform.container }}
maturin-version: v1.10.1
- name: Upload wheel
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: wheel-${{ matrix.platform.name }}-${{ matrix.platform.target }}
path: target/wheels/*.whl
sdist:
name: Build a source distribution (.tar.gz)
if: (github.event_name == 'release' && contains(github.event.release.tag_name, 'python')) || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.event.release.tag_name || github.ref }}
- name: Build sdist
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
with:
command: sdist
working-directory: bindings/python/src
- name: Upload sdist
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: sdist
path: target/wheels/*.tar.gz
publish:
runs-on: ubuntu-latest
needs: [wheels, sdist]
permissions:
id-token: write
attestations: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
pattern: "*"
merge-multiple: true
path: dist
- name: Ensure wheels and sdist exist
run: |
shopt -s nullglob
files=( dist/*.whl dist/*.tar.gz )
(( ${#files[@]} )) || { echo "No data found to upload"; exit 1; }
echo "Publishing:"
printf ' - %s\n' "${files[@]}"
- name: Generate artifact attestation
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
with:
subject-path: dist
- name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch' && inputs.test_publish == true
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist
skip-existing: true
verbose: true
attestations: true
verify-metadata: true
- name: Publish to PyPI
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.test_publish == false)
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
packages-dir: dist
skip-existing: true
verbose: true
attestations: true
verify-metadata: true