|
1 | 1 | # Rust Build Workflow |
2 | 2 |
|
3 | | -A reusable GitHub Actions workflow for building, linting, testing, and publishing Rust packages, with optional dependency caching and working directory support. |
| 3 | +A reusable GitHub Actions workflow for building, linting, testing, and auditing Rust packages, with optional artifact upload and crates.io publishing. |
4 | 4 |
|
5 | 5 | ## Features |
6 | 6 |
|
7 | 7 | - Build and test Rust packages |
8 | 8 | - Lint code using `clippy` |
9 | 9 | - Check formatting with `cargo fmt` |
| 10 | +- Run security audits with `cargo audit` |
10 | 11 | - Cache dependencies for faster builds |
11 | | -- Set a working directory (for monorepos or nested crates) |
| 12 | +- Set a working directory for monorepos |
| 13 | +- Upload build artifacts |
12 | 14 | - Publish to crates.io |
| 15 | +- All operations are performed in a single job (no redundant toolchain installs) |
13 | 16 |
|
14 | 17 | ## Usage |
15 | 18 |
|
|
23 | 26 | uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main |
24 | 27 | with: |
25 | 28 | working-directory: './my-crate' |
| 29 | + run-audit: true |
26 | 30 | enable-cache: true |
27 | | - publish-crates-io: false |
| 31 | + upload-artifact: true |
| 32 | + artifact-name: my-crate |
| 33 | + artifact-path: target/release/my-crate |
28 | 34 | secrets: |
29 | 35 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
30 | 36 | ``` |
|
34 | 40 | | Name | Description | Default | Required | |
35 | 41 | | ------------------- | --------------------------------------------------------- | -------- | -------- | |
36 | 42 | | `working-directory` | The directory to run jobs from | `.` | No | |
| 43 | +| `run-audit` | Run `cargo audit` for security vulnerabilities | `true` | No | |
37 | 44 | | `enable-cache` | Enable caching of dependencies | `true` | No | |
| 45 | +| `upload-artifact` | Upload a build artifact after building | `false` | No | |
| 46 | +| `artifact-name` | Name of the artifact to upload | – | No | |
| 47 | +| `artifact-path` | Path to the artifact to upload | – | No | |
38 | 48 | | `publish-crates-io` | Publish the package to crates.io (only if build succeeds) | `false` | No | |
39 | 49 |
|
40 | 50 | Note: All builds use the release profile by default. There is no build-target input anymore |
|
65 | 75 | working-directory: './my-crate' |
66 | 76 | ``` |
67 | 77 |
|
| 78 | +### Disable Security Audit |
| 79 | + |
| 80 | +```yaml |
| 81 | +jobs: |
| 82 | + build-and-test: |
| 83 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main |
| 84 | + with: |
| 85 | + run-audit: false |
| 86 | +``` |
| 87 | + |
| 88 | +### Upload Artifact After Build |
| 89 | + |
| 90 | +```yaml |
| 91 | +jobs: |
| 92 | + build-and-upload: |
| 93 | + uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main |
| 94 | + with: |
| 95 | + upload-artifact: true |
| 96 | + artifact-name: my-crate |
| 97 | + artifact-path: target/release/my-crate |
| 98 | +``` |
| 99 | + |
68 | 100 | ### Publish to crates.io (requires CARGO_REGISTRY_TOKEN) |
69 | 101 |
|
70 | 102 | ```yaml |
|
0 commit comments