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