|
| 1 | +name: Publish Rust Crates |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'rust-v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + dry_run: |
| 10 | + description: 'Perform a dry run without publishing' |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + default: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish: |
| 17 | + name: Publish to crates.io |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Setup Rust |
| 24 | + uses: ./.github/actions/rust-setup |
| 25 | + with: |
| 26 | + cache-key: publish |
| 27 | + |
| 28 | + - name: Check crate versions |
| 29 | + run: | |
| 30 | + echo "=== Checking crate versions ===" |
| 31 | + echo "rollkit-types version: $(cargo pkgid -p rollkit-types | cut -d# -f2)" |
| 32 | + echo "rollkit-client version: $(cargo pkgid -p rollkit-client | cut -d# -f2)" |
| 33 | +
|
| 34 | + - name: Run tests |
| 35 | + run: cargo test --workspace --all-features |
| 36 | + |
| 37 | + - name: Package crates |
| 38 | + run: | |
| 39 | + cargo package -p rollkit-types --allow-dirty |
| 40 | + cargo package -p rollkit-client --allow-dirty |
| 41 | +
|
| 42 | + - name: Publish rollkit-types (dry run) |
| 43 | + if: github.event_name == 'workflow_dispatch' && inputs.dry_run |
| 44 | + run: | |
| 45 | + cd client/crates/rollkit-types |
| 46 | + cargo publish --dry-run |
| 47 | +
|
| 48 | + - name: Publish rollkit-client (dry run) |
| 49 | + if: github.event_name == 'workflow_dispatch' && inputs.dry_run |
| 50 | + run: | |
| 51 | + cd client/crates/rollkit-client |
| 52 | + cargo publish --dry-run |
| 53 | +
|
| 54 | + - name: Publish rollkit-types |
| 55 | + if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) |
| 56 | + env: |
| 57 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 58 | + run: | |
| 59 | + cd client/crates/rollkit-types |
| 60 | + cargo publish |
| 61 | +
|
| 62 | + - name: Wait for rollkit-types to be available |
| 63 | + if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) |
| 64 | + run: | |
| 65 | + echo "Waiting for rollkit-types to be available on crates.io..." |
| 66 | + sleep 30 |
| 67 | +
|
| 68 | + - name: Publish rollkit-client |
| 69 | + if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) |
| 70 | + env: |
| 71 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 72 | + run: | |
| 73 | + cd client/crates/rollkit-client |
| 74 | + cargo publish |
| 75 | +
|
| 76 | + - name: Create GitHub Release |
| 77 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| 78 | + uses: softprops/action-gh-release@v2 |
| 79 | + with: |
| 80 | + name: Rust Client ${{ github.ref_name }} |
| 81 | + body: | |
| 82 | + # Rust Client Release |
| 83 | +
|
| 84 | + This release includes: |
| 85 | + - `rollkit-types`: Proto-generated types for Rollkit |
| 86 | + - `rollkit-client`: High-level Rust client for Rollkit gRPC services |
| 87 | +
|
| 88 | + ## Installation |
| 89 | +
|
| 90 | + Add to your `Cargo.toml`: |
| 91 | + ```toml |
| 92 | + [dependencies] |
| 93 | + rollkit-client = "<version>" |
| 94 | + ``` |
| 95 | +
|
| 96 | + See the [README](https://github.com/rollkit/rollkit/tree/main/client/crates/rollkit-client) for usage examples. |
| 97 | + draft: false |
| 98 | + prerelease: false |
0 commit comments