Skip to content

Commit a3d97bb

Browse files
committed
feat: prepare for crates.io publishing
- Configure package metadata for crates.io - Add GitHub workflows for automated publishing and releases - Create CHANGELOG.md for version tracking - Add PUBLISHING.md with publishing guide - Add CLAUDE.md with codebase instructions - Fix unused import warning - Set binary name as 'abi2human'
1 parent 53a47fa commit a3d97bb

File tree

7 files changed

+346
-4
lines changed

7 files changed

+346
-4
lines changed

.github/workflows/publish.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
publish:
13+
name: Publish to crates.io
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Cache cargo registry
23+
uses: actions/cache@v3
24+
with:
25+
path: |
26+
~/.cargo/bin/
27+
~/.cargo/registry/index/
28+
~/.cargo/registry/cache/
29+
~/.cargo/git/db/
30+
target/
31+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
33+
- name: Run tests
34+
run: cargo test --all-features
35+
36+
- name: Check formatting
37+
run: cargo fmt -- --check
38+
39+
- name: Run clippy
40+
run: cargo clippy --all-targets --all-features -- -D warnings
41+
42+
- name: Publish to crates.io
43+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
44+
env:
45+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/release.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create-release:
13+
name: Create GitHub Release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Extract version from tag
22+
id: get_version
23+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
24+
25+
- name: Create GitHub Release
26+
id: create_release
27+
uses: actions/create-release@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
tag_name: ${{ github.ref }}
32+
release_name: Release ${{ steps.get_version.outputs.VERSION }}
33+
draft: false
34+
prerelease: false
35+
body: |
36+
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.
37+
38+
build-and-upload:
39+
name: Build and Upload Binaries
40+
needs: create-release
41+
strategy:
42+
matrix:
43+
include:
44+
- target: x86_64-unknown-linux-gnu
45+
os: ubuntu-latest
46+
name: abi2human-linux-amd64
47+
- target: x86_64-apple-darwin
48+
os: macos-latest
49+
name: abi2human-macos-amd64
50+
- target: aarch64-apple-darwin
51+
os: macos-latest
52+
name: abi2human-macos-arm64
53+
- target: x86_64-pc-windows-msvc
54+
os: windows-latest
55+
name: abi2human-windows-amd64.exe
56+
57+
runs-on: ${{ matrix.os }}
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v4
61+
62+
- name: Install Rust
63+
uses: dtolnay/rust-toolchain@stable
64+
with:
65+
targets: ${{ matrix.target }}
66+
67+
- name: Build binary
68+
run: cargo build --release --target ${{ matrix.target }}
69+
70+
- name: Prepare binary (Unix)
71+
if: matrix.os != 'windows-latest'
72+
run: |
73+
cd target/${{ matrix.target }}/release
74+
strip abi2human
75+
mv abi2human ../../../${{ matrix.name }}
76+
77+
- name: Prepare binary (Windows)
78+
if: matrix.os == 'windows-latest'
79+
run: |
80+
cd target/${{ matrix.target }}/release
81+
move abi2human.exe ../../../${{ matrix.name }}
82+
83+
- name: Upload binary
84+
uses: actions/upload-release-asset@v1
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
with:
88+
upload_url: ${{ needs.create-release.outputs.upload_url }}
89+
asset_path: ./${{ matrix.name }}
90+
asset_name: ${{ matrix.name }}
91+
asset_content_type: application/octet-stream

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [1.0.0] - 2025-01-06
11+
12+
### Added
13+
- Initial release of abi2human
14+
- Zero-dependency Ethereum ABI to human-readable converter
15+
- Support for functions, events, constructors, receive, and fallback
16+
- Multiple output formats: JSON array, raw text, compact JSON
17+
- Batch processing for directories
18+
- Stream processing via stdin/stdout
19+
- Comprehensive test suite
20+
21+
### Features
22+
- Convert single ABI files
23+
- Convert entire directories with pattern matching
24+
- Pipeline support for integration with other tools
25+
- Multiple output format options
26+
- Human-readable function and event signatures
27+
28+
[Unreleased]: https://github.com/yourusername/abi2human-rs/compare/v1.0.0...HEAD
29+
[1.0.0]: https://github.com/yourusername/abi2human-rs/releases/tag/v1.0.0

CLAUDE.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
### Build
8+
```bash
9+
# Debug build
10+
cargo build
11+
12+
# Release build (optimized)
13+
cargo build --release
14+
```
15+
16+
### Test
17+
```bash
18+
# Run all tests
19+
cargo test
20+
21+
# Run tests with output
22+
cargo test -- --nocapture
23+
24+
# Run specific test
25+
cargo test test_name
26+
```
27+
28+
### Lint & Format
29+
```bash
30+
# Format code
31+
cargo fmt
32+
33+
# Check formatting without applying
34+
cargo fmt -- --check
35+
36+
# Run clippy for linting
37+
cargo clippy
38+
39+
# Run clippy with all targets
40+
cargo clippy --all-targets --all-features
41+
```
42+
43+
### Run
44+
```bash
45+
# Run debug version
46+
cargo run -- [args]
47+
48+
# Run release version
49+
cargo run --release -- [args]
50+
51+
# Or use the compiled binary
52+
./target/release/abi2human [args]
53+
```
54+
55+
## Architecture
56+
57+
This is a zero-dependency Rust CLI tool that converts Ethereum ABI JSON to human-readable format. The codebase is modular with clear separation of concerns:
58+
59+
### Core Modules
60+
61+
- **`abi.rs`**: Defines ABI data structures (`AbiItem`, `AbiInput`, `AbiOutput`) and implements their Display traits for human-readable formatting
62+
- **`json_parser.rs`**: Custom JSON parser that handles ABI parsing without external dependencies
63+
- **`converter.rs`**: Orchestrates the conversion process - parses ABI content and formats output
64+
- **`file_ops.rs`**: Handles all file I/O operations including single file, directory, and stdin/stdout processing
65+
- **`main.rs`**: CLI entry point with argument parsing and command routing
66+
- **`tests.rs`**: Comprehensive test suite
67+
68+
### Key Design Patterns
69+
70+
1. **Zero Dependencies**: All JSON parsing and formatting is implemented from scratch to avoid supply chain risks
71+
2. **Stream Processing**: The tool can process stdin to stdout for pipeline integration
72+
3. **Batch Operations**: Supports converting entire directories with pattern matching
73+
4. **Multiple Output Formats**: JSON array, raw text, or compact JSON
74+
75+
### Data Flow
76+
77+
1. Input (file/directory/stdin) →
78+
2. JSON Parser (converts to ABI structures) →
79+
3. Converter (formats to human-readable) →
80+
4. Output (file/stdout with chosen format)
81+
82+
The tool is designed to be fast, secure, and easily auditable with no external dependencies.

Cargo.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22
name = "abi2human"
33
version = "1.0.0"
44
edition = "2021"
5-
authors = ["Your Name"]
6-
description = "Convert Ethereum ABI to human-readable format"
7-
license = "MIT"
5+
authors = ["Your Name <[email protected]>"]
6+
description = "Zero-dependency CLI tool to convert Ethereum ABI JSON to human-readable format"
7+
license = "MIT OR Apache-2.0"
8+
repository = "https://github.com/yourusername/abi2human-rs"
9+
homepage = "https://github.com/yourusername/abi2human-rs"
10+
documentation = "https://docs.rs/abi2human"
11+
readme = "README.md"
12+
keywords = ["ethereum", "abi", "converter", "cli", "blockchain"]
13+
categories = ["command-line-utilities", "development-tools", "cryptography::cryptocurrencies"]
14+
exclude = ["tests/*", ".github/*", "examples/*"]
815

916
[[bin]]
1017
name = "abi2human"

PUBLISHING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Publishing Guide for abi2human
2+
3+
## Prerequisites
4+
5+
1. **Crates.io Account**: Create an account at https://crates.io/
6+
2. **API Token**: Generate a token at https://crates.io/me
7+
3. **GitHub Repository**: Update the repository URLs in `Cargo.toml`
8+
9+
## Setup GitHub Secrets
10+
11+
Add your crates.io API token as a GitHub secret:
12+
1. Go to your repository's Settings → Secrets and variables → Actions
13+
2. Click "New repository secret"
14+
3. Name: `CARGO_REGISTRY_TOKEN`
15+
4. Value: Your crates.io API token
16+
17+
## Local Publishing (Manual)
18+
19+
### 1. Test Build
20+
```bash
21+
cargo build --release
22+
cargo test
23+
cargo clippy -- -D warnings
24+
cargo fmt -- --check
25+
```
26+
27+
### 2. Dry Run
28+
```bash
29+
cargo publish --dry-run
30+
```
31+
32+
### 3. Publish to crates.io
33+
```bash
34+
cargo publish
35+
```
36+
37+
## Automated Publishing (GitHub Actions)
38+
39+
### 1. Update Version
40+
Edit `Cargo.toml`:
41+
```toml
42+
version = "1.0.1" # Increment version
43+
```
44+
45+
### 2. Update CHANGELOG
46+
Add your changes to `CHANGELOG.md`
47+
48+
### 3. Commit and Tag
49+
```bash
50+
git add .
51+
git commit -m "chore: release v1.0.1"
52+
git tag -a v1.0.1 -m "Release version 1.0.1"
53+
git push origin main
54+
git push origin v1.0.1
55+
```
56+
57+
The GitHub Actions will automatically:
58+
- Run tests
59+
- Check formatting and linting
60+
- Publish to crates.io
61+
- Create GitHub release with binaries for:
62+
- Linux (x86_64)
63+
- macOS (x86_64 and ARM64)
64+
- Windows (x86_64)
65+
66+
## Version Management
67+
68+
Follow [Semantic Versioning](https://semver.org/):
69+
- MAJOR: Breaking changes
70+
- MINOR: New features (backwards compatible)
71+
- PATCH: Bug fixes
72+
73+
## Pre-release Checklist
74+
75+
- [ ] All tests pass (`cargo test`)
76+
- [ ] Code is formatted (`cargo fmt`)
77+
- [ ] No clippy warnings (`cargo clippy`)
78+
- [ ] README.md is up to date
79+
- [ ] CHANGELOG.md includes new changes
80+
- [ ] Version bumped in Cargo.toml
81+
- [ ] Repository URLs in Cargo.toml are correct
82+
- [ ] Author information is correct
83+
84+
## Post-release
85+
86+
After successful publication:
87+
1. Verify on https://crates.io/crates/abi2human
88+
2. Test installation: `cargo install abi2human`
89+
3. Verify binaries in GitHub release

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ mod tests;
77
use std::env;
88
use std::path::Path;
99
use std::process;
10-
use std::io::{self, Write};
1110
use file_ops::{ConvertOptions, convert_file, convert_directory, convert_stdin_to_stdout};
1211
use converter::Converter;
1312

0 commit comments

Comments
 (0)