Skip to content

Commit e6ebab1

Browse files
delsnerborchero
andauthored
build: Use cargo-auditable for rust build (#334)
Co-authored-by: Oliver Borchert <me@borchero.com>
1 parent 15218de commit e6ebab1

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,36 @@ jobs:
5757
environments: build
5858
- name: Set version
5959
run: pixi run -e build set-version
60+
- name: Install cargo-auditable
61+
if: github.event_name == 'release' && runner.os != 'Linux'
62+
run: cargo install cargo-auditable@0.7.4 --locked
63+
- name: Prepare cargo-auditable wrapper (macOS)
64+
if: github.event_name == 'release' && runner.os == 'macOS'
65+
run: |
66+
# cargo-auditable must be invoked as "cargo auditable <cmd>", not as a direct CARGO
67+
# replacement — the latter does not support "cargo rustc --profile". A wrapper delegates
68+
# to the real cargo via PATH (no recursion risk since CARGO is set via env, not PATH).
69+
printf '#!/bin/sh\nexec cargo auditable "$@"\n' > /usr/local/bin/cargo-auditable-wrapper
70+
chmod +x /usr/local/bin/cargo-auditable-wrapper
71+
echo "CARGO=/usr/local/bin/cargo-auditable-wrapper" >> "$GITHUB_ENV"
72+
- name: Prepare cargo-auditable wrapper (Windows)
73+
if: github.event_name == 'release' && runner.os == 'Windows'
74+
shell: bash
75+
run: |
76+
printf '@cargo auditable %%*\n' > "C:/cargo-auditable-wrapper.cmd"
77+
echo "CARGO=C:\\cargo-auditable-wrapper.cmd" >> "$GITHUB_ENV"
6078
- name: Build wheel
6179
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
6280
with:
6381
command: build
6482
args: --out dist --release -i python3.10
6583
manylinux: auto
66-
sccache: true
84+
sccache: ${{ github.event_name != 'release' }}
85+
# NOTE: We also need to set up cargo-auditable inside the docker container
86+
# where the linux build is performed.
87+
docker-options: ${{ case(github.event_name == 'release', format('-e CARGO={0}', env.CARGO), '') }}
88+
before-script-linux: |
89+
${{ case(github.event_name == 'release', 'cargo install cargo-auditable@0.7.4 --locked && printf ''#!/bin/sh\nexec cargo auditable "$@"\n'' > /usr/local/bin/cargo-auditable-wrapper && chmod +x /usr/local/bin/cargo-auditable-wrapper', '') }}
6790
- name: Check package
6891
run: pixi run -e build check-wheel
6992
- name: Upload package

0 commit comments

Comments
 (0)