-
Notifications
You must be signed in to change notification settings - Fork 41
180 lines (153 loc) · 5.84 KB
/
bindings-python-publish.yml
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
179
180
name: Create Python Release
on: workflow_dispatch
env:
CARGO_INCREMENTAL: 0
jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
- name: Get current date
if: matrix.os == 'windows-2019'
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
# Add date to the cache to keep it up to date
key: ${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }}
# Restore from outdated cache for speed
restore-keys: |
${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}
${{ matrix.os }}-stable-cargo-index-
- name: Install LLVM and Clang (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd
if: matrix.os == 'windows-latest'
with:
version: "11.0"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH (Windows)
if: matrix.os == 'windows-latest'
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
# Set custom deployment target because of rocksdb
- name: Set deployment target (macOS)
run: echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV
if: matrix.os == 'macos-latest'
- name: Install required packages (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Build wheels
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest'
uses: PyO3/maturin-action@v1
with:
args: --release --out dist -m bindings/python/Cargo.toml -i python${{ matrix.python-version }}
- name: Build wheels for --target aarch64-apple-darwin
if: matrix.os == 'macos-latest'
uses: PyO3/maturin-action@v1
with:
args: --target aarch64-apple-darwin --release --out dist -m bindings/python/Cargo.toml -i python${{ matrix.python-version }}
# Build without container on linux
- name: Build wheels
if: matrix.os == 'ubuntu-latest'
uses: PyO3/maturin-action@v1
with:
manylinux: auto
container: off
args: --release --out dist -m bindings/python/Cargo.toml -i python${{ matrix.python-version }}
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
build-wheels-aarch64:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
docker-container:
[
"python:3.9.12-slim-bullseye",
"python:3.10.10-slim-bullseye",
"python:3.11.1-slim-bullseye",
]
steps:
- name: Checkout
uses: actions/checkout@v3 # Required to mount the Github Workspace to a volume
- uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.docker-container }}
options: -v ${{ github.workspace }}:/root
run: |
cd root
apt-get update
apt-get install -y git curl build-essential libudev-dev libusb-1.0-0-dev pkg-config clang
curl https://sh.rustup.rs -sSf | sh -s -- -y
. "$HOME/.cargo/env"
cd bindings/python
pip install -r requirements-dev.txt
pip install patchelf
pip install maturin
maturin build --out ../../../dist --release
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
release:
name: Release
runs-on: ubuntu-latest
needs: [build-wheels, build-wheels-aarch64]
steps:
- uses: actions/checkout@v3
- name: Get tag name
id: tagname
run: |
cd bindings/python
tagName="iota-sdk-python-$(cargo read-manifest | jq -r '.version')"
echo $tagName
echo "TAG_NAME=$tagName" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v3
with:
name: wheels
path: wheels
- run: ls -R
- name: Upload Wheels to Github
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: wheels/*
tag_name: ${{ steps.tagname.outputs.TAG_NAME }}
append_body: true
prerelease: true
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pip install --upgrade twine
twine upload --skip-existing wheels/*