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
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and Release

on:
push:
tags:
- "v*" # 每次打 tag 时触发,比如 v0.1.0

permissions:
contents: write

jobs:
build:
name: Build binaries for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Build
run: cargo build --release --target ${{ matrix.target }}

- name: Prepare artifact (non-Windows)
if: matrix.os != 'windows-latest'
shell: bash
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/pbf-craft dist/
tar czf dist/pbf-craft-${{ matrix.target }}.tar.gz -C dist pbf-craft
echo "Contents of dist:"
ls -lh dist

- name: Prepare artifact (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item -Path "target\${{ matrix.target}}\release\pbf-craft.exe" -Destination dist\
Compress-Archive -Path dist\pbf-craft.exe -DestinationPath "dist\pbf-craft-${{ matrix.target }}.zip" -Force
Get-ChildItem dist


- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pbf-craft-${{ matrix.target }}
path: dist/
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist

- name: Check built artifacts
run: |
echo "==> Files in workspace:"
ls -R .
echo "==> Files in dist:"
ls -R dist

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/**/*.{tar.gz,zip}
overwrite_files: true
generate_release_notes: true

22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Repository Guidelines

## Project Structure & Module Organization
The workspace roots two crates: `pbf-craft/` (core library) and `pbf-craft-cli/` (command-line client). Library modules live under `pbf-craft/src/`, with codecs, readers, writers, and models split into dedicated folders for focused ownership. CLI subcommands are grouped in `pbf-craft-cli/src/commands/`, while Postgres access layers sit in `pbf-craft-cli/src/db/`. Sample PBF fixtures are stored in `pbf-craft/resources/`, and build artifacts land in `target/`; keep generated files out of version control unless explicitly needed.

## Build, Test, and Development Commands
- `cargo build --workspace` – compile both crates and ensure shared interfaces stay compatible.
- `cargo run -p pbf-craft-cli -- --help` – confirm the CLI starts and prints the supported subcommands.
- `cargo test --workspace` – execute all unit and integration tests; run before every PR.
- `cargo fmt` and `cargo clippy --workspace --all-targets` – enforce formatting and linting prior to committing.

## Coding Style & Naming Conventions
The codebase targets Rust 2021 with the default 4-space indentation. Use `cargo fmt` to standardize layout and respect rustfmt defaults for imports and expression wrapping. Follow Rust idioms: modules and functions in `snake_case`, types and traits in `CamelCase`, constants in `SCREAMING_SNAKE_CASE`. Prefer explicit `Result<T, anyhow::Error>` returns and `?` propagation. Keep protobuf schema changes isolated in `pbf-craft/build.rs` inputs so generated code stays reproducible.

## Testing Guidelines
Unit tests should live beside the code under `#[cfg(test)] mod tests` blocks; mimic the patterns in `pbf-craft/src/codecs/block_builder.rs` when adding coverage. Use `cargo test -p pbf-craft --lib` to focus on the library and `cargo test -p pbf-craft-cli` when exercising CLI helpers. When a feature depends on sample data, reference files under `pbf-craft/resources/` and document the fixture in the test name. Aim to cover new public APIs with deterministic assertions and add regression tests for every bug fix.

## Commit & Pull Request Guidelines
Commit history favors concise Conventional-style prefixes (for example, `refactor: tune indexed reader cache` or `cicd: remove clippy step`). Write present-tense subjects that explain the why, not the how. Pull requests should include: a short summary, linked issues or tickets, the commands you ran (`cargo test`, `cargo clippy`, etc.), and CLI output or screenshots when a user-facing command changes. Request review from owners of affected modules and wait for CI to pass before merging.

## Data & Configuration Tips
The CLI expects a Postgres instance populated with OSM extracts; configure host, port, database, user, and password through the `DatabaseReader` constructor or equivalent wiring. Store sensitive credentials outside the repo (for example, local `.env` files ignored by Git). For quick manual checks, run `cargo run -p pbf-craft-cli -- export --help` to see required connection flags. Keep large PBF downloads in `resources/` or `.cache/` paths that are excluded from commits.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion pbf-craft-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[package]
name = "pbf-craft-cli"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
authors = ["Lurker <cloverzero@gmail.com>"]
repository = "https://github.com/cloverzero/pbf-craft"
homepage = "https://github.com/cloverzero/pbf-craft"
description = "A command-line utility for OpenStreetMap PBF file format."
readme = "README.md"
categories = ["encoding", "parser-implementations"]
keywords = ["openstreetmap", "osm", "pbf", "protocolbuffer", "protobuf"]
license = "MIT"

[dependencies]
anyhow = { version = "1.0", features = ["backtrace"] }
Expand All @@ -18,3 +26,7 @@ postgres = { version = "0.19.4", features = ["with-chrono-0_4"] }
postgres-types = { version = "0.2.4", features = ["derive"] }
serde = { version = "1.0.142", features = ["derive"] }
serde_json = "1.0.83"

[[bin]]
name = "pbf-craft"
path = "src/main.rs"
6 changes: 3 additions & 3 deletions pbf-craft/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "pbf-craft"
version = "0.9.2"
version = "0.10.0"
edition = "2021"
authors = ["Lurker <cloverzero@gmail.com>"]
repository = "https://github.com/nextbillion-ai/pbf-craft"
homepage = "https://github.com/nextbillion-ai/pbf-craft"
repository = "https://github.com/cloverzero/pbf-craft"
homepage = "https://github.com/cloverzero/pbf-craft"
description = "A Rust library for reading and writing OpenSteetMap PBF file format."
readme = "README.md"
categories = ["encoding", "parser-implementations"]
Expand Down
Loading