-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (154 loc) · 5.89 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
154
155
156
157
158
159
name: build and release
on:
push:
tags:
- 'v[0-9]*'
#branches:
#- main
#pull_request:
# ^ uncomment when testing changes to build
concurrency:
group: >
${{ github.workflow }} @
${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-13]
cibw-build-prefix: ['*']
include:
- os: ubuntu-20.04
cibw-build-prefix: cp*
- os: ubuntu-20.04
cibw-build-prefix: pp*
exclude:
- os: ubuntu-20.04
cibw-build-prefix: '*'
steps:
- uses: actions/checkout@v3
- name: Restore mtimes of files in repo
uses: chetan/[email protected]
- name: Cargo home cache
uses: actions/cache@v3
env:
cache-name: cargo-home
with:
path: ~/cargo-home-dirs
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.cibw-build-prefix }}-v10.0
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.cibw-build-prefix }}-v10.
- name: Rust build cache
uses: actions/cache@v3
env:
cache-name: rust-build
with:
path: ~/cargo-target-dirs
key: ${{ env.cache-name }}-${{ runner.os }}-v10.0-${{ matrix.cibw-build-prefix }}-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.cibw-build-prefix }}-v10.
- name: Save env vars for cibuildwheel
run: >
echo "MAIN_DIR=$PWD" >> "$GITHUB_ENV";
echo "OUTER_HOME=$HOME" >> "$GITHUB_ENV";
cat "$GITHUB_ENV"
shell: bash
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: >
${{ matrix.cibw-build-prefix }}
CIBW_SKIP: >
*musllinux*
CIBW_ENVIRONMENT_LINUX: >
HOST_HOME_DIR="/host/${{ env.OUTER_HOME }}"
HOST_PROJ_DIR="/host/${{ env.MAIN_DIR }}"
PROJ_DIR="/project"
PATH="/host/${{ env.OUTER_HOME }}/.cargo/bin:$PATH"
CARGO_HOME="/host/${{ env.OUTER_HOME }}/.cargo"
RUSTUP_HOME="/host/${{ env.OUTER_HOME }}/.rustup"
CARGO_TARGET_DIR="/host/${{ env.OUTER_HOME }}/target"
CARGO_LOG="cargo::core::compiler::fingerprint=info"
HOST_HOME_DIR_UNIX="/host/${{ env.OUTER_HOME }}"
CARGO_HOME_UNIX="/host/${{ env.OUTER_HOME }}/.cargo"
RUSTUP_HOME_UNIX="/host/${{ env.OUTER_HOME }}/.rustup"
CARGO_TARGET_DIR_UNIX="/host/${{ env.OUTER_HOME }}/target"
CIBW_ENVIRONMENT_MACOS: >
HOST_HOME_DIR="$HOME"
HOST_PROJ_DIR="$GITHUB_WORKSPACE"
PROJ_DIR="$GITHUB_WORKSPACE"
PATH="$HOME/.cargo/bin:$PATH"
CARGO_HOME="$HOME/.cargo"
RUSTUP_HOME="$HOME/.rustup"
CARGO_TARGET_DIR="$HOME/target"
CARGO_LOG="cargo::core::compiler::fingerprint=info"
HOST_HOME_DIR_UNIX="$HOME"
CARGO_HOME_UNIX="$HOME/.cargo"
RUSTUP_HOME_UNIX="$HOME/.rustup"
CARGO_TARGET_DIR_UNIX="$HOME/target"
CIBW_ENVIRONMENT_WINDOWS: >
HOST_HOME_DIR="$HOME"
HOST_PROJ_DIR="$GITHUB_WORKSPACE"
PROJ_DIR="$GITHUB_WORKSPACE"
PATH="$HOME\\.cargo\\bin;$PATH"
CARGO_HOME="$HOME\\.cargo"
RUSTUP_HOME="$HOME\\.rustup"
CARGO_TARGET_DIR="$HOME\\target"
CARGO_LOG="cargo::core::compiler::fingerprint=info"
HOST_HOME_DIR_UNIX="${{ env.OUTER_HOME }}"
CARGO_HOME_UNIX="${{ env.OUTER_HOME }}/.cargo"
RUSTUP_HOME_UNIX="${{ env.OUTER_HOME }}/.rustup"
CARGO_TARGET_DIR_UNIX="${{ env.OUTER_HOME }}/target"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_BEFORE_BUILD_LINUX: >
bash $PROJ_DIR/ci-utils/before-build-linux.sh
CIBW_BEFORE_BUILD_MACOS: >
bash $PROJ_DIR/ci-utils/before-build-mac.sh
CIBW_BEFORE_BUILD_WINDOWS: >
bash ci-utils/before-build-win.sh
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
auditwheel repair -w {dest_dir} {wheel};
bash $PROJ_DIR/ci-utils/after-build.sh
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
cp {wheel} {dest_dir} &
bash %PROJ_DIR%/ci-utils/after-build.sh
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
delocate-listdeps {wheel} && delocate-wheel --require-archs \
{delocate_archs} -w {dest_dir} {wheel};
bash $PROJ_DIR/ci-utils/after-build.sh
CIBW_BUILD_VERBOSITY: 1
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: pipx run build --sdist
- name: Install tool to post-process sdist to make extension optional
run: pip install 'postprocess-sdist-make-rust-ext-opt>=0.2,<0.3'
- name: Post-process sdist to make extension optional
run: postprocess-sdist-make-rust-ext-opt -fO dist dist/*.tar.gz
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# testing:
#repository_url: https://test.pypi.org/legacy/
#password: ${{ secrets.TEST_PYPI_API_TOKEN }}