Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Publish to crates.io

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (no actual publish)'
required: false
default: 'true'
type: boolean
crate:
description: 'Crate to publish (all, fetchkit, fetchkit-cli)'
required: false
default: 'all'
type: choice
options:
- all
- fetchkit
- fetchkit-cli

permissions:
contents: read

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
test:
name: Test before publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --workspace
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --workspace --all-targets -- -D warnings

publish-fetchkit:
name: Publish fetchkit
needs: test
runs-on: ubuntu-latest
if: >-
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' &&
(github.event.inputs.crate == 'all' || github.event.inputs.crate == 'fetchkit'))
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: Verify crate can be packaged
run: cargo package -p fetchkit --allow-dirty

- name: Publish fetchkit (dry run)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true'
run: cargo publish -p fetchkit --dry-run

- name: Publish fetchkit
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false')
run: cargo publish -p fetchkit
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

publish-fetchkit-cli:
name: Publish fetchkit-cli
needs: [test, publish-fetchkit]
runs-on: ubuntu-latest
if: >-
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' &&
(github.event.inputs.crate == 'all' || github.event.inputs.crate == 'fetchkit-cli'))
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

# Wait for crates.io index to update after fetchkit publish
- name: Wait for crates.io index
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false')
run: sleep 30

- name: Verify crate can be packaged
run: cargo package -p fetchkit-cli --allow-dirty

- name: Publish fetchkit-cli (dry run)
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'true'
run: cargo publish -p fetchkit-cli --dry-run

- name: Publish fetchkit-cli
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false')
run: cargo publish -p fetchkit-cli
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
31 changes: 31 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Key capabilities:

Available specs:
- `specs/initial.md` - WebFetch tool specification (types, behavior, conversions, error handling)
- `specs/fetchers.md` - Pluggable fetcher system for URL-specific handling

Specification format: Abstract and Requirements sections.

Expand Down Expand Up @@ -91,6 +92,36 @@ specs/ # Feature specifications
- Clippy runs with `-D warnings` (warnings are errors)
- Doc builds must not have warnings

### Publishing to crates.io

Workflow: `.github/workflows/publish.yml`

Triggers:
- Push version tag: `v*.*.*` or `v*.*.*-*` (e.g., `v0.1.0`, `v0.2.0-beta.1`)
- Manual workflow dispatch with dry-run option

Process:
1. Runs tests, fmt check, and clippy
2. Publishes `fetchkit` library first
3. Waits for crates.io index update
4. Publishes `fetchkit-cli`

Requirements:
- `CARGO_REGISTRY_TOKEN` secret must be configured in repo settings
- Crate metadata (name, version, description, license, repository) in Cargo.toml

Release steps:
```bash
# 1. Update version in Cargo.toml (workspace level)
# 2. Commit version bump
git commit -am "chore: bump version to 0.2.0"
# 3. Create and push tag
git tag v0.2.0
git push origin main --tags
```

Note: `fetchkit-python` is not published to crates.io (uses PyPI distribution instead).

### Cloud Agent environments

When running in cloud-hosted agent environments (e.g., Claude Code on the web), the following secrets are available:
Expand Down
2 changes: 1 addition & 1 deletion crates/fetchkit-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name = "fetchkit"
path = "src/main.rs"

[dependencies]
fetchkit = { path = "../fetchkit" }
fetchkit = { version = "0.1.0", path = "../fetchkit" }
tokio = { workspace = true }
clap = { workspace = true }
serde = { workspace = true }
Expand Down