ci(build): Add build-failure-alert job to workflow
#743
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 | |
| on: [push, pull_request] | |
| permissions: {} | |
| jobs: | |
| cargo-toml-features: | |
| name: Generate Feature Combinations | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| feature-combinations: ${{ steps.cargo-toml-features.outputs.feature-combinations }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Determine Cargo Features | |
| id: cargo-toml-features | |
| uses: Holzhaus/cargo-toml-features-action@3afa751aae4071b2d1ca1c5fa42528a351c995f4 | |
| build: | |
| needs: cargo-toml-features | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| strategy: | |
| matrix: | |
| features: ${{ fromJson(needs.cargo-toml-features.outputs.feature-combinations) }} | |
| env: | |
| CRATE_FEATURES: ${{ join(matrix.features, ',') }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Print Rust version | |
| run: rustc -vV | |
| - name: Build Package | |
| run: | # zizmor: ignore[use-trusted-publishing] | |
| cargo publish --dry-run --locked --no-default-features --features "${CRATE_FEATURES}" | |
| - name: Run Tests | |
| run: cargo test --locked --no-default-features --features "${CRATE_FEATURES}" | |
| - name: Run Benchmark | |
| run: cargo bench --locked --no-default-features --features "${CRATE_FEATURES}" | |
| - name: Generate Documentation | |
| run: cargo doc --no-deps --locked --no-default-features --features "${CRATE_FEATURES}" | |
| build-failure-alert: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: ${{ cancelled() || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') }} | |
| steps: | |
| - name: Conditionally Fail Required Check | |
| shell: bash | |
| run: | | |
| echo "::error Some build job has failed!" | |
| exit 1 | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # Required for OIDC token exchange | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Authenticate with registry | |
| id: auth | |
| uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 | |
| - name: Publish Package | |
| run: cargo publish --locked | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |