Skip to content

Commit ddacb2a

Browse files
feat: add crates.io publish workflow and package config (#3490)
- Add include filter to Cargo.toml (750 -> 235 files) for clean crate packaging - Add publish-crates.yml workflow for manual crates.io publishing with dry-run support - Add crates-io job to release-stable-manual.yml for auto-publish on stable releases - Requires CARGO_REGISTRY_TOKEN secret to be configured in repo settings
1 parent 77ca576 commit ddacb2a

3 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to publish (e.g. 0.2.0) — must match Cargo.toml"
8+
required: true
9+
type: string
10+
dry_run:
11+
description: "Dry run (validate without publishing)"
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
concurrency:
17+
group: publish-crates
18+
cancel-in-progress: false
19+
20+
permissions:
21+
contents: read
22+
23+
env:
24+
CARGO_TERM_COLOR: always
25+
26+
jobs:
27+
validate:
28+
name: Validate
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Check version matches Cargo.toml
33+
shell: bash
34+
env:
35+
INPUT_VERSION: ${{ inputs.version }}
36+
run: |
37+
set -euo pipefail
38+
cargo_version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)
39+
if [[ "$cargo_version" != "$INPUT_VERSION" ]]; then
40+
echo "::error::Cargo.toml version (${cargo_version}) does not match input (${INPUT_VERSION})"
41+
exit 1
42+
fi
43+
44+
publish:
45+
name: Publish to crates.io
46+
needs: [validate]
47+
runs-on: ubuntu-latest
48+
timeout-minutes: 30
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: dtolnay/rust-toolchain@stable
53+
with:
54+
toolchain: 1.92.0
55+
56+
- uses: Swatinem/rust-cache@v2
57+
58+
- uses: actions/setup-node@v4
59+
with:
60+
node-version: 22
61+
cache: npm
62+
cache-dependency-path: web/package-lock.json
63+
64+
- name: Build web dashboard
65+
run: cd web && npm ci && npm run build
66+
67+
- name: Verify package
68+
run: cargo package --locked
69+
70+
- name: Publish (dry run)
71+
if: inputs.dry_run
72+
run: cargo publish --dry-run --locked
73+
env:
74+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
75+
76+
- name: Publish to crates.io
77+
if: "!inputs.dry_run"
78+
run: cargo publish --locked
79+
env:
80+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/release-stable-manual.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,34 @@ jobs:
263263
--notes-file release-notes.md \
264264
--latest
265265
266+
crates-io:
267+
name: Publish to crates.io
268+
needs: [validate, publish]
269+
runs-on: ubuntu-latest
270+
timeout-minutes: 30
271+
steps:
272+
- uses: actions/checkout@v4
273+
274+
- uses: dtolnay/rust-toolchain@stable
275+
with:
276+
toolchain: 1.92.0
277+
278+
- uses: Swatinem/rust-cache@v2
279+
280+
- uses: actions/setup-node@v4
281+
with:
282+
node-version: 22
283+
cache: npm
284+
cache-dependency-path: web/package-lock.json
285+
286+
- name: Build web dashboard
287+
run: cd web && npm ci && npm run build
288+
289+
- name: Publish to crates.io
290+
run: cargo publish --locked
291+
env:
292+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
293+
266294
redeploy-website:
267295
name: Trigger Website Redeploy
268296
needs: [publish]

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ readme = "README.md"
1414
keywords = ["ai", "agent", "cli", "assistant", "chatbot"]
1515
categories = ["command-line-utilities", "api-bindings"]
1616
rust-version = "1.87"
17+
include = [
18+
"/src/**/*",
19+
"/build.rs",
20+
"/Cargo.toml",
21+
"/Cargo.lock",
22+
"/LICENSE*",
23+
"/README.md",
24+
"/web/dist/**/*",
25+
]
1726

1827
[dependencies]
1928
# CLI - minimal and fast

0 commit comments

Comments
 (0)