32
32
args : --exclude windows-redirector --exclude macos-certificate-truster
33
33
steps :
34
34
- uses : actions/checkout@v3
35
- - uses : actions/cache@v3
36
- with :
37
- path : |
38
- ~/.cargo/bin/
39
- ~/.cargo/registry/index/
40
- ~/.cargo/registry/cache/
41
- ~/.cargo/git/db/
42
- target/
43
- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
35
+ - uses : Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
44
36
- name : Set up Rust toolchain
45
37
run : rustup toolchain install ${{ matrix.rust }} --profile minimal
46
38
- uses : actions/setup-python@v4
@@ -62,47 +54,62 @@ jobs:
62
54
command : test
63
55
args : --workspace --verbose ${{ matrix.args }}
64
56
65
- build-windows :
66
- runs-on : windows-latest
57
+ build :
58
+ strategy :
59
+ matrix :
60
+ include :
61
+ - os : windows-latest
62
+ - os : ubuntu-latest
63
+ args : --compatibility manylinux2014 --zig --sdist
64
+ - os : ubuntu-latest
65
+ target : aarch64-unknown-linux-gnu
66
+ args : --compatibility manylinux2014 --zig --target aarch64-unknown-linux-gnu
67
+ - os : macos-latest
68
+ target : aarch64-apple-darwin
69
+ args : --target universal2-apple-darwin
70
+ runs-on : ${{ matrix.os }}
71
+ name : build-wheel (${{ matrix.os }}, ${{ matrix.target || 'x64' }})
67
72
steps :
68
73
- uses : actions/checkout@v3
69
- - uses : actions/cache@v3
70
- with :
71
- path : |
72
- ~/.cargo/bin/
73
- ~/.cargo/registry/index/
74
- ~/.cargo/registry/cache/
75
- ~/.cargo/git/db/
76
- target/
77
- key : windows-redirector-${{ hashFiles('**/Cargo.lock') }}
74
+ - uses : Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
78
75
- run : rustup toolchain install stable --profile minimal
79
76
- run : rustup default stable
77
+ - if : matrix.target
78
+ run : rustup target add ${{ matrix.target }}
79
+ - run : rustup show
80
80
- uses : actions/setup-python@v4
81
81
with :
82
82
python-version-file : .github/python-version.txt
83
- - name : Install build from PyPI
84
- uses : install-pinned/build@11bbf2deeb1a44228c45910f3b57e346927960b4
85
83
86
- - run : cargo build --release --package windows-redirector
87
- - run : python -m build --wheel mitmproxy-windows --outdir target/wheels/
84
+ - name : Install maturin[zig] from PyPI
85
+ uses : install-pinned/maturin-with-zig@930de5c8284dfb26f11fd30a35a0df4c15ee4f8b
86
+
87
+ - if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
88
+ run : |
89
+ VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version)
90
+ sed -i "s/mitmproxy_windows/mitmproxy_windows==$VERSION/g" mitmproxy-rs/pyproject.toml
91
+ sed -i "s/mitmproxy_macos/mitmproxy_macos==$VERSION/g" mitmproxy-rs/pyproject.toml
92
+
93
+ - run : maturin build --release ${{ matrix.args }}
94
+ working-directory : ./mitmproxy-rs
88
95
89
96
- uses : actions/upload-artifact@v3
90
97
with :
91
98
name : wheels
92
99
path : target/wheels
93
100
94
- build-macos :
101
+ build-macos-app :
95
102
runs-on : macos-latest
96
103
steps :
97
104
- uses : actions/checkout@v3
98
105
- uses : actions/cache@v3
99
106
id : cache-app
100
107
with :
101
- path : macos- redirector/dist/
102
- key : macos-${{ hashFiles('macos- redirector/**', '.github/scripts/build-macos-redirector.sh') }}
108
+ path : mitmproxy-macos/ redirector/dist/
109
+ key : macos-${{ hashFiles('mitmproxy-macos/ redirector/**', '.github/scripts/build-macos-redirector.sh') }}
103
110
- if : steps.cache-app.outputs.cache-hit != 'true'
104
- run : .. /.github/scripts/build-macos-redirector.sh
105
- working-directory : macos- redirector
111
+ run : $GITHUB_WORKSPACE /.github/scripts/build-macos-redirector.sh
112
+ working-directory : mitmproxy-macos/ redirector
106
113
env :
107
114
APPLE_ID : ${{ secrets.APPLE_ID }}
108
115
APPLE_APP_PASSWORD : ${{ secrets.APPLE_APP_PASSWORD }}
@@ -113,83 +120,64 @@ jobs:
113
120
- uses : actions/upload-artifact@v3
114
121
with :
115
122
name : macos-app
116
- path : macos- redirector/dist/
123
+ path : mitmproxy-macos/ redirector/dist/
117
124
118
- build :
119
- needs : build-macos
125
+ build-os-wheels :
126
+ needs : build-macos-app
120
127
strategy :
121
128
matrix :
122
129
include :
123
- - os : windows-latest
124
- - os : ubuntu-latest
125
- args : --compatibility manylinux2014 --zig --sdist
126
- - os : ubuntu-latest
127
- target : aarch64-unknown-linux-gnu
128
- args : --compatibility manylinux2014 --zig --target aarch64-unknown-linux-gnu
129
- - os : macos-latest
130
- target : aarch64-apple-darwin
131
- args : --target universal2-apple-darwin
132
- runs-on : ${{ matrix.os }}
133
- name : build-wheel (${{ matrix.os }}, ${{ matrix.target || 'x64' }})
130
+ - os : windows
131
+ build-rust : --package windows-redirector
132
+ - os : macos
133
+ build-rust : --package macos-certificate-truster
134
+ runs-on : ${{ matrix.os }}-latest
135
+ name : build mitmproxy-${{ matrix.os }}
134
136
steps :
135
137
- uses : actions/checkout@v3
136
- - uses : actions/cache@v3
137
- with :
138
- path : |
139
- ~/.cargo/bin/
140
- ~/.cargo/registry/index/
141
- ~/.cargo/registry/cache/
142
- ~/.cargo/git/db/
143
- target/
144
- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
138
+
139
+ # Build Rust
140
+ - uses : Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
145
141
- run : rustup toolchain install stable --profile minimal
146
142
- run : rustup default stable
147
- - if : matrix.target
148
- run : rustup target add ${{ matrix.target }}
149
- - run : rustup show
150
- - uses : actions/setup-python@v4
151
- with :
152
- python-version-file : .github/python-version.txt
153
-
154
- - name : Install maturin[zig] from PyPI
155
- uses : install-pinned/maturin-with-zig@930de5c8284dfb26f11fd30a35a0df4c15ee4f8b
156
-
157
- - if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
158
- run : |
159
- VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r .packages[0].version)
160
- sed -i "s/mitmproxy_windows/mitmproxy_windows==$VERSION/g" ffi/pyproject.toml
143
+ - run : cargo build --release ${{ matrix.build-rust }}
161
144
162
- - if : runner.os == 'macOS'
163
- run : cargo build --release --package macos-certificate-truster
145
+ # Download macOS app
164
146
- if : runner.os == 'macOS'
165
147
uses : actions/download-artifact@v3
166
148
with :
167
149
name : macos-app
168
- path : macos-redirector/dist/
169
-
170
- - run : maturin build --release ${{ matrix.args }}
171
- working-directory : ./ffi
150
+ path : mitmproxy-macos/redirector/dist/
172
151
152
+ # Build & upload wheel
153
+ - uses : actions/setup-python@v4
154
+ with :
155
+ python-version-file : .github/python-version.txt
156
+ - name : Install build from PyPI
157
+ uses : install-pinned/build@3f4552ef2aab2ffefe2461e1cb506609d0dbf07a
158
+ - run : python -m build --wheel ./mitmproxy-${{ matrix.os }} --outdir target/wheels/
173
159
- uses : actions/upload-artifact@v3
174
160
with :
175
161
name : wheels
176
162
path : target/wheels
177
- deploy :
178
- uses : mhils/workflows/.github/workflows/python-deploy.yml@main
179
- needs : [test, build]
180
- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
181
- with :
182
- artifact : wheels
183
- # repository: testpypi
184
- # environment: deploy-testpypi
185
- secrets :
186
- password : ${{ secrets.PYPI_TOKEN }}
187
163
188
164
check :
189
165
if : always()
190
166
needs :
191
167
- test
192
168
- build
169
+ - build-os-wheels
193
170
uses : mhils/workflows/.github/workflows/alls-green.yml@main
194
171
with :
195
172
jobs : ${{ toJSON(needs) }}
173
+
174
+ deploy :
175
+ uses : mhils/workflows/.github/workflows/python-deploy.yml@main
176
+ needs : check
177
+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
178
+ with :
179
+ artifact : wheels
180
+ # repository: testpypi
181
+ # environment: deploy-testpypi
182
+ secrets :
183
+ password : ${{ secrets.PYPI_TOKEN }}
0 commit comments