forked from ngrok/ngrok-python
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (153 loc) · 7.39 KB
/
build.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
on:
workflow_call:
inputs:
docker:
required: false
type: string
host:
required: true
type: string
if:
description: 'Whether to run this job'
required: false
default: true
type: boolean
publish:
required: false
type: string
setup:
required: false
type: string
target:
required: true
type: string
jobs:
reusable-build:
if: ${{ inputs.if }}
name: stable - ${{ inputs.target }} - node@18
runs-on: ${{ inputs.host }}
steps:
- uses: actions/checkout@v3
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ inputs.target }}-cargo-${{ inputs.host }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ inputs.target == 'armv7-unknown-linux-gnueabihf' }}
with:
version: 0.10.0
- name: Setup toolchain
run: ${{ inputs.setup }}
if: ${{ inputs.setup }}
shell: bash
- name: x86_64-unknown-linux-musl
uses: addnab/docker-run-action@v3
if: ${{ inputs.target == 'x86_64-unknown-linux-musl' }}
with:
image: ${{ inputs.docker }}
options: '-e SHOULD_PUBLISH=${{ inputs.publish }} --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: |
pwd
ls -lah
whoami
env
apk update
apk add --no-cache python3 py3-pip
python3 -m venv .env
. .env/bin/activate && pip install -r requirements.txt
. .env/bin/activate && pip install patchelf
if [ "${SHOULD_PUBLISH}" == 'true' ]; then
echo "~~~~ maturin publishing"
. .env/bin/activate && maturin publish --no-sdist -u __token__ -p ${{ secrets.MATURIN_PASSWORD }}
else
echo "~~~~ maturin building"
. .env/bin/activate && maturin build
fi
- name: aarch64-unknown-linux-gnu
uses: addnab/docker-run-action@v3
if: ${{ inputs.target == 'aarch64-unknown-linux-gnu' }}
with:
image: ${{ inputs.docker }}
options: '-e SHOULD_PUBLISH=${{ inputs.publish }} --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
run: |
pwd
ls -lah
whoami
env
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
export PATH="$HOME/.cargo/bin:$PATH"
# ring 0.17 assembly build needs __ARM_ARCH set
export CFLAGS_aarch64_unknown_linux_gnu="-D__ARM_ARCH=8"
rustup component add llvm-tools-preview || true
rustup target add aarch64-unknown-linux-gnu
python3 -m venv .env
. .env/bin/activate && pip install -r requirements.txt
. .env/bin/activate && pip install patchelf
# this is in raw 'sh', use single '='
if [ "${SHOULD_PUBLISH}" = 'true' ]; then
echo "~~~~ maturin publishing"
# pass '--debug' to avoid optimization, which breaks tls signature validation on this platform
. .env/bin/activate && maturin publish --target ${{ inputs.target }} --no-sdist --debug -u __token__ -p ${{ secrets.MATURIN_PASSWORD }}
else
echo "~~~~ maturin building"
. .env/bin/activate && maturin build --target ${{ inputs.target }}
fi
- name: Build aarch64-linux-android
if: ${{ inputs.target == 'aarch64-linux-android' }}
uses: PyO3/maturin-action@v1
with:
target: ${{ inputs.target }}
args: --release -i python3.9 -m Cargo.toml
docker-options: |
--mount type=bind,source=/usr/local/lib/android/sdk/ndk/25.2.9519653,target=/usr/local/lib/android/sdk/ndk/25.2.9519653
-e CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang
-e CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-androideabi24-clang
-e CC=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang
-e CXX=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++
-e AR=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
-e ANDROID_NDK=/usr/local/lib/android/sdk/ndk/25.2.9519653
- name: Build armv7-linux-androideabi
if: ${{ inputs.target == 'armv7-linux-androideabi' }}
uses: PyO3/maturin-action@v1
with:
target: ${{ inputs.target }}
args: --release -i python3.9 -m Cargo.toml
docker-options: |
--mount type=bind,source=/usr/local/lib/android/sdk/ndk/25.2.9519653,target=/usr/local/lib/android/sdk/ndk/25.2.9519653
-e CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang
-e CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang
-e CC=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang
-e CXX=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++
-e AR=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
-e ANDROID_NDK=/usr/local/lib/android/sdk/ndk/25.2.9519653
- name: Setup x86 Python
if: ${{ inputs.target == 'i686-pc-windows-msvc' }}
uses: actions/setup-python@v4
with:
python-version: "3.9"
architecture: "x86"
- name: Build
if: ${{ inputs.publish != 'true' && !inputs.docker && !contains(inputs.target,'android') }}
uses: PyO3/maturin-action@v1
with:
target: ${{ inputs.target }}
args: --release -i python3.9 -m Cargo.toml
- name: Publish
if: ${{ inputs.publish == 'true' && !inputs.docker && !contains(inputs.target,'android') }}
uses: PyO3/maturin-action@v1
with:
command: publish
target: ${{ inputs.target }}
args: --no-sdist -i python3.9 -m Cargo.toml -u __token__ -p ${{ secrets.MATURIN_PASSWORD }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ inputs.target }}
path: target/wheels/*.whl
if-no-files-found: error