Add CARGO_EXTRA_ARGS #4
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 Rust project | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| pull_request: | |
| branches: | |
| - "master" | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| cargo_profile: [ "debug", "release" ] | |
| os: [ "windows-latest", "ubuntu-latest" ] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Print tool versions | |
| run: | | |
| rustup --version | |
| cargo --version | |
| rustc --version | |
| # NOTE: stupid workaround for cargo erroring on "--debug". | |
| - name: Set Cargo extra args | |
| if: ${{ 'matrix.cargo_profile' == 'release' }} | |
| run: echo "CARGO_EXTRA_ARGS=--release" >> $GITHUB_ENV | |
| - name: Run Cargo build | |
| run: | | |
| cargo build \ | |
| --verbose \ | |
| --features cxx/c++20 \ | |
| --features cxx/std \ | |
| ${{ env.CARGO_EXTRA_ARGS }} | |
| - name: Archive build artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: rust-cxx-${{ matrix.os }}-${{ matrix.cargo_profile }} | |
| path: target/ |