Skip to content

Commit 8da0355

Browse files
authored
Move macOS binaries into separate package (#98)
1 parent 7387ffe commit 8da0355

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+119
-193
lines changed

.github/dependabot.yml

-12
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,3 @@ updates:
1212
directory: "/"
1313
schedule:
1414
interval: "monthly"
15-
- package-ecosystem: cargo
16-
directory: "/ffi"
17-
schedule:
18-
interval: "monthly"
19-
- package-ecosystem: cargo
20-
directory: "/mitmproxy-windows/redirector"
21-
schedule:
22-
interval: "monthly"
23-
- package-ecosystem: cargo
24-
directory: "/wireguard-test-client"
25-
schedule:
26-
interval: "monthly"

.github/scripts/build-macos-redirector.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -eou pipefail
44

5-
if [ -n "${APPLE_ID+x}" ]; then
5+
if [ -n "${APPLE_ID-}" ]; then
66
echo "Signing keys available, building signed binary..."
77

88
APPLE_TEAM_ID=S8XHQB96PW
@@ -53,4 +53,6 @@ if [ -n "${APPLE_ID+x}" ]; then
5353
else
5454
echo "Signing keys not available, building unsigned binary..."
5555
xcodebuild -scheme macos-redirector CODE_SIGNING_ALLOWED="NO" build
56+
mkdir dist
57+
touch dist/dev-build
5658
fi

.github/workflows/autofix.yml

+2-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v3
2121
- run: brew install swift-protobuf
22-
- run: protoc --swift_out=./macos-redirector/ipc --proto_path=./src/packet_sources/ ipc.proto
22+
- run: protoc --swift_out=./mitmproxy-macos/redirector/ipc --proto_path=./src/packet_sources/ ipc.proto
2323
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
2424

2525
rustfmt:
@@ -35,15 +35,7 @@ jobs:
3535
args: --workspace --exclude windows-redirector --exclude macos-certificate-truster
3636
steps:
3737
- uses: actions/checkout@v3
38-
- uses: actions/cache@v3
39-
with:
40-
path: |
41-
~/.cargo/bin/
42-
~/.cargo/registry/index/
43-
~/.cargo/registry/cache/
44-
~/.cargo/git/db/
45-
target/
46-
key: ${{ runner.os }}-autofix-${{ hashFiles('**/Cargo.lock') }}
38+
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
4739

4840
- run: rustup toolchain install ${{ env.rust_clippy }} --profile minimal --component rustfmt --component clippy
4941
- run: rustup default ${{ env.rust_clippy }}

.github/workflows/ci.yml

+70-82
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,7 @@ jobs:
3232
args: --exclude windows-redirector --exclude macos-certificate-truster
3333
steps:
3434
- 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
4436
- name: Set up Rust toolchain
4537
run: rustup toolchain install ${{ matrix.rust }} --profile minimal
4638
- uses: actions/setup-python@v4
@@ -62,47 +54,62 @@ jobs:
6254
command: test
6355
args: --workspace --verbose ${{ matrix.args }}
6456

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' }})
6772
steps:
6873
- 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
7875
- run: rustup toolchain install stable --profile minimal
7976
- run: rustup default stable
77+
- if: matrix.target
78+
run: rustup target add ${{ matrix.target }}
79+
- run: rustup show
8080
- uses: actions/setup-python@v4
8181
with:
8282
python-version-file: .github/python-version.txt
83-
- name: Install build from PyPI
84-
uses: install-pinned/build@11bbf2deeb1a44228c45910f3b57e346927960b4
8583

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
8895

8996
- uses: actions/upload-artifact@v3
9097
with:
9198
name: wheels
9299
path: target/wheels
93100

94-
build-macos:
101+
build-macos-app:
95102
runs-on: macos-latest
96103
steps:
97104
- uses: actions/checkout@v3
98105
- uses: actions/cache@v3
99106
id: cache-app
100107
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') }}
103110
- 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
106113
env:
107114
APPLE_ID: ${{ secrets.APPLE_ID }}
108115
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
@@ -113,83 +120,64 @@ jobs:
113120
- uses: actions/upload-artifact@v3
114121
with:
115122
name: macos-app
116-
path: macos-redirector/dist/
123+
path: mitmproxy-macos/redirector/dist/
117124

118-
build:
119-
needs: build-macos
125+
build-os-wheels:
126+
needs: build-macos-app
120127
strategy:
121128
matrix:
122129
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 }}
134136
steps:
135137
- 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
145141
- run: rustup toolchain install stable --profile minimal
146142
- 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 }}
161144

162-
- if: runner.os == 'macOS'
163-
run: cargo build --release --package macos-certificate-truster
145+
# Download macOS app
164146
- if: runner.os == 'macOS'
165147
uses: actions/download-artifact@v3
166148
with:
167149
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/
172151

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/
173159
- uses: actions/upload-artifact@v3
174160
with:
175161
name: wheels
176162
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 }}
187163

188164
check:
189165
if: always()
190166
needs:
191167
- test
192168
- build
169+
- build-os-wheels
193170
uses: mhils/workflows/.github/workflows/alls-green.yml@main
194171
with:
195172
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 }}

.github/workflows/docs.yml

+3-11
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v3
23-
- uses: actions/cache@v3
24-
with:
25-
path: |
26-
~/.cargo/bin/
27-
~/.cargo/registry/index/
28-
~/.cargo/registry/cache/
29-
~/.cargo/git/db/
30-
target/
31-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
23+
- uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
3224

3325
- name: Install maturin[zig] from PyPI
3426
uses: install-pinned/maturin-with-zig@930de5c8284dfb26f11fd30a35a0df4c15ee4f8b
@@ -38,10 +30,10 @@ jobs:
3830
uses: install-pinned/pdoc@9c418cd240bd030d158f48187a6aa9946439b51e
3931

4032
- run: maturin build
41-
working-directory: ./ffi
33+
working-directory: ./mitmproxy-rs
4234
- run: pip install --no-index --find-links target/wheels/ mitmproxy_rs
4335

44-
- run: stubtest --allowlist ffi/stubtest-allowlist.txt --mypy-config-file ffi/pyproject.toml mitmproxy_rs
36+
- run: stubtest --allowlist mitmproxy-rs/stubtest-allowlist.txt --mypy-config-file mitmproxy-rs/pyproject.toml mitmproxy_rs
4537

4638
- run: pdoc -o docs/ mitmproxy_rs
4739

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ virtualenv activated and run the following:
1111
pip install maturin
1212
git clone https://github.com/mitmproxy/mitmproxy_rs.git
1313

14-
cd mitmproxy_rs/ffi
14+
cd mitmproxy_rs/mitmproxy-rs
1515
maturin develop
1616
```
1717

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[workspace]
22
members = [
33
".",
4-
"ffi",
4+
"mitmproxy-rs",
55
"mitmproxy-windows/redirector",
66
"wireguard-test-client",
7-
"macos-certificate-truster",
7+
"mitmproxy-macos/certificate-truster",
88
]
99

1010
[workspace.package]

ffi/build.rs

-66
This file was deleted.

0 commit comments

Comments
 (0)