|
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 |
|
|
26 | 23 | uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main |
27 | 24 | with: |
28 | 25 | working-directory: './my-crate' |
29 | | - run-audit: true |
30 | 26 | enable-cache: true |
31 | | - upload-artifact: true |
32 | | - artifact-name: my-crate |
33 | | - artifact-path: target/release/my-crate |
| 27 | + publish-crates-io: false |
34 | 28 | secrets: |
35 | 29 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
36 | 30 | ``` |
|
40 | 34 | | Name | Description | Default | Required | |
41 | 35 | | ------------------- | --------------------------------------------------------- | -------- | -------- | |
42 | 36 | | `working-directory` | The directory to run jobs from | `.` | No | |
43 | | -| `run-audit` | Run `cargo audit` for security vulnerabilities | `true` | No | |
44 | 37 | | `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 | |
48 | 38 | | `publish-crates-io` | Publish the package to crates.io (only if build succeeds) | `false` | No | |
49 | 39 |
|
50 | 40 | Note: All builds use the release profile by default. There is no build-target input anymore |
|
75 | 65 | working-directory: './my-crate' |
76 | 66 | ``` |
77 | 67 |
|
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 | | - |
100 | 68 | ### Publish to crates.io (requires CARGO_REGISTRY_TOKEN) |
101 | 69 |
|
102 | 70 | ```yaml |
|
0 commit comments