This repository was archived by the owner on May 22, 2025. It is now read-only.
Rust #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: Rust | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| os: | |
| description: The operating system to use | |
| required: true | |
| type: string | |
| repository: | |
| description: The repository to build on | |
| required: true | |
| type: string | |
| profile: | |
| description: The profile for build | |
| type: choice | |
| options: | |
| - dev | |
| - release | |
| - release-lite | |
| - release-with-debug | |
| default: 'dev' | |
| extract: | |
| description: Extract specific binary from the dist | |
| type: string | |
| ref: | |
| description: Ref a Branch/Tag/SHA whatever to checkout | |
| type: string | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| runs-on: ${{ inputs.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ inputs.repository }} | |
| ref: ${{ inputs.ref }} | |
| - name: Cache Cargo home | |
| uses: actions/cache@v4 | |
| with: | |
| path: |- | |
| ~/.cargo/.crates.toml | |
| ~/.cargo/.crates2.json | |
| ~/.cargo/bin | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| key: '31-cargo-home-${{ inputs.os }}-${{ inputs.repository }}-${{ hashFiles(''Cargo.lock'') }}' | |
| restore-keys: '31-cargo-home-${{ inputs.os }}-${{ inputs.repository }}-' | |
| - name: Restore cache build output | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: |- | |
| ./target | |
| !./target/*/gn_out | |
| !./target/*/gn_root | |
| !./target/*/*.zip | |
| !./target/*/*.tar.gz | |
| key: never_saved | |
| restore-keys: '31-cargo-target-${{ inputs.os }}-${{ inputs.repository }}-' | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/[email protected] | |
| - name: Set Rust caching env | |
| run: | | |
| echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV | |
| echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV | |
| - name: Setup Rust toolchains | |
| run: | | |
| rustup default nightly | |
| - name: Build (${{ inputs.profile }}) | |
| run: 'cargo +nightly build --profile ${{ inputs.profile }} --verbose --artifact-dir dist -Z unstable-options' | |
| - name: Upload extracts (${{ inputs.profile }}) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Target Extracts | |
| path: | | |
| ${{ inputs.extract }} | |
| - name: Upload artifacts (${{ inputs.profile }}) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Target Artifacts | |
| path: | | |
| dist/* | |
| - name: Save cache build output (main) | |
| uses: actions/cache/save@v4 | |
| if: always() | |
| with: | |
| path: |- | |
| ./target | |
| ./target/build | |
| !./target/*/gn_out | |
| !./target/*/gn_root | |
| !./target/*/*.zip | |
| !./target/*/*.tar.gz | |
| key: '31-cargo-target-${{ inputs.os }}-${{ inputs.repository }}-' | |