From 2f94a0225a42929afca1c13f9f9e3b0886ee1f6b Mon Sep 17 00:00:00 2001 From: "cloverzero@gmail.com" Date: Fri, 31 Oct 2025 22:48:56 +0800 Subject: [PATCH 1/2] update versions to publish --- .github/workflows/release.yml | 85 +++++++++++++++++++++++++++++++++++ AGENTS.md | 22 +++++++++ Cargo.lock | 6 +-- pbf-craft-cli/Cargo.toml | 6 ++- pbf-craft/Cargo.toml | 2 +- 5 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 AGENTS.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..75cb52a --- /dev/null +++ b/.github/workflows/release.yml @@ -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 + diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..6002de4 --- /dev/null +++ b/AGENTS.md @@ -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` 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. diff --git a/Cargo.lock b/Cargo.lock index a6610b3..b71ba92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -851,7 +851,7 @@ dependencies = [ [[package]] name = "pbf-craft" -version = "0.9.2" +version = "0.10.0" dependencies = [ "anyhow", "base16ct", @@ -869,7 +869,7 @@ dependencies = [ [[package]] name = "pbf-craft-cli" -version = "0.1.0" +version = "0.2.0" dependencies = [ "anyhow", "chrono", diff --git a/pbf-craft-cli/Cargo.toml b/pbf-craft-cli/Cargo.toml index 66c616d..34ee44f 100644 --- a/pbf-craft-cli/Cargo.toml +++ b/pbf-craft-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbf-craft-cli" -version = "0.1.0" +version = "0.2.0" edition = "2021" [dependencies] @@ -18,3 +18,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" diff --git a/pbf-craft/Cargo.toml b/pbf-craft/Cargo.toml index 31b49d2..109e7d3 100644 --- a/pbf-craft/Cargo.toml +++ b/pbf-craft/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbf-craft" -version = "0.9.2" +version = "0.10.0" edition = "2021" authors = ["Lurker "] repository = "https://github.com/nextbillion-ai/pbf-craft" From 82c9daaf25c6c6a803c4053bb6df4158bba87568 Mon Sep 17 00:00:00 2001 From: "cloverzero@gmail.com" Date: Fri, 31 Oct 2025 22:55:25 +0800 Subject: [PATCH 2/2] update the repository urls --- pbf-craft-cli/Cargo.toml | 8 ++++++++ pbf-craft/Cargo.toml | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pbf-craft-cli/Cargo.toml b/pbf-craft-cli/Cargo.toml index 34ee44f..4020164 100644 --- a/pbf-craft-cli/Cargo.toml +++ b/pbf-craft-cli/Cargo.toml @@ -2,6 +2,14 @@ name = "pbf-craft-cli" version = "0.2.0" edition = "2021" +authors = ["Lurker "] +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"] } diff --git a/pbf-craft/Cargo.toml b/pbf-craft/Cargo.toml index 109e7d3..34ba844 100644 --- a/pbf-craft/Cargo.toml +++ b/pbf-craft/Cargo.toml @@ -3,8 +3,8 @@ name = "pbf-craft" version = "0.10.0" edition = "2021" authors = ["Lurker "] -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"]