Fix macOS arm64 release build: undefined dynamic_lookup linker flags #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release Rust Router | |
| # Builds prebuilt grid_router binaries for Linux x86_64, macOS arm64, and | |
| # Windows x86_64 whenever a version tag (vX.Y.Z) is pushed, then attaches them | |
| # to a GitHub Release so users can install without a Rust toolchain. | |
| # | |
| # The Rust crate uses pyo3 abi3-py39, so one binary per platform works for | |
| # every Python 3.9+ interpreter. | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: # allow manual runs from the Actions tab | |
| permissions: | |
| contents: write # needed to create/update the GitHub Release | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target_name }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target_name: linux-x86_64 | |
| artifact_src: rust_router/target/release/libgrid_router.so | |
| artifact_dst: grid_router-linux-x86_64.so | |
| extra_rustflags: '' | |
| - os: macos-14 | |
| target_name: macos-arm64 | |
| artifact_src: rust_router/target/release/libgrid_router.dylib | |
| artifact_dst: grid_router-macos-arm64.so | |
| # pyo3's extension-module needs these on macOS so Python symbols | |
| # resolve at load time inside the interpreter instead of at link | |
| # time. Locally pyo3-build-config sets this for you; in CI it | |
| # doesn't always, so set it explicitly. | |
| extra_rustflags: '-C link-arg=-undefined -C link-arg=dynamic_lookup' | |
| - os: windows-latest | |
| target_name: windows-x86_64 | |
| artifact_src: rust_router/target/release/grid_router.dll | |
| artifact_dst: grid_router-windows-x86_64.pyd | |
| extra_rustflags: '' | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry and target | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| rust_router/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust_router/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build release binary | |
| env: | |
| RUSTFLAGS: ${{ matrix.extra_rustflags }} | |
| run: cargo build --release --manifest-path rust_router/Cargo.toml | |
| - name: Stage artifact | |
| shell: bash | |
| run: cp "${{ matrix.artifact_src }}" "${{ matrix.artifact_dst }}" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_dst }} | |
| path: ${{ matrix.artifact_dst }} | |
| if-no-files-found: error | |
| release: | |
| name: Publish GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| # Only publish a Release when a tag was pushed; manual runs just produce | |
| # downloadable workflow artifacts. | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Download all built binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: List downloaded files | |
| run: ls -la artifacts | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: artifacts/* | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true |