Skip to main content

A production-ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.

Project description

Rust Project Template

Crates.io Crates.io Downloads npm version npm downloads rust tests code-quality license PRs

🚀 A production‑ready Rust project template to bootstrap new projects fast. It includes a clean Cargo layout, Docker, and a complete CI/CD suite.

Click Use this template to start a new repository from this scaffold.

Other Languages: English | 繁體中文 | 简体中文

✨ Highlights

  • Modern Cargo layout (src/lib.rs, src/main.rs, tests/)
  • Lint & format with clippy and rustfmt
  • GitHub Actions: tests, quality, package build, Docker publish, release drafter, Rust-aware labeler, secret scans, semantic PR, weekly dependency update
  • Multi-stage Dockerfile producing a minimal runtime image

🚀 Quick Start

Prerequisites: Rust toolchain (rustup), Docker (optional)

make fmt            # rustfmt + clippy
make test           # cargo test (all targets)
make test-verbose   # cargo test (all targets with verbose output)
make coverage       # generate LCOV coverage report
make build          # cargo build (release mode)
make build-release  # cargo build --release
make run            # run the release binary
make clean          # clean build artifacts and caches
make package        # build crate package (allow dirty)
make help           # list targets

🐳 Docker

docker build -f docker/Dockerfile --target prod -t ghcr.io/<owner>/<repo>:latest .
docker run --rm ghcr.io/<owner>/<repo>:latest

Or using the actual binary name:

docker build -f docker/Dockerfile --target prod -t rust_template:latest .
docker run --rm rust_template:latest

📦 Packaging

make package        # build crate package (allow dirty)
# or use cargo directly:
cargo package --locked --allow-dirty
# CARGO_REGISTRY_TOKEN=... cargo publish

CI builds run automatically on tags matching v* and upload the .crate file. Uncomment the publish step in build_package.yml to automate crates.io releases.

🧩 Cross Builds

This template does not ship cross-compile tooling by default. If you need cross or zig-based builds locally, install and configure them per your environment.

GitHub Actions build_release.yml builds multi-platform release binaries on tags matching v* and uploads them to the GitHub Release assets.

Targets:

  • x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl
  • aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl
  • x86_64-apple-darwin, aarch64-apple-darwin
  • x86_64-pc-windows-msvc, aarch64-pc-windows-msvc

Assets naming:

  • <bin>-v<version>-<target>.tar.gz (all platforms)
  • <bin>-v<version>-<target>.zip (Windows additionally)

🔁 CI/CD Workflows

Main Workflows

  • Tests (test.yml): cargo build/test + generate LCOV coverage report and upload artifact
  • Code Quality (code-quality-check.yml): rustfmt check + clippy (deny warnings)
  • Build Package (build_package.yml): package on tag v*, optional crates.io publish
  • Publish Docker Image (build_image.yml): push to GHCR on main/master and tags v*
  • Build Release (build_release.yml): Linux release binaries uploaded on tags v*

Additional Automation

  • Auto Labeler (auto_labeler.yml): automatically label PRs based on branch names and file changes
  • Code Scan (code_scan.yml): multi-layer security scanning (GitLeaks, Trufflehog secret scanning, CodeQL code analysis, Trivy vulnerability scanning)
  • Release Drafter (release_drafter.yml): auto-generate release notes
  • Semantic PR (semantic-pull-request.yml): enforce PR title format
  • Dependabot weekly dependency updates

🤝 Contributing

  • Open issues/PRs

  • Use Conventional Commits for PR titles

  • Keep code formatted and clippy‑clean

  • After every edit, run cargo build to confirm compilation is successful

  • Before opening a PR, please run locally:

    • cargo fmt --all -- --check
    • cargo clippy --all-targets --all-features -- -D warnings
    • cargo test

📄 License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rust_template-0.1.23.tar.gz (814.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rust_template-0.1.23-py3-none-any.whl (815.2 kB view details)

Uploaded Python 3

File details

Details for the file rust_template-0.1.23.tar.gz.

File metadata

  • Download URL: rust_template-0.1.23.tar.gz
  • Upload date:
  • Size: 814.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.0

File hashes

Hashes for rust_template-0.1.23.tar.gz
Algorithm Hash digest
SHA256 2c8a97018684fef4b851b7127be38007586063f7e78c74edb1353670f32732ee
MD5 50857da74258658a116525ad9c0b2a3f
BLAKE2b-256 44ce976f34a174e0f9d81d5c5f53e3e08606c552ed970de542dc98d02bf51481

See more details on using hashes here.

File details

Details for the file rust_template-0.1.23-py3-none-any.whl.

File metadata

File hashes

Hashes for rust_template-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 628328bc640425158b0b8b82bb8aaa254082a7d2fc3f639f5c2a1c1eb0d3d229
MD5 d187f00f6231613a97d337b4d189f3d8
BLAKE2b-256 d904541d4d6326f5b2885bb32df10be77e132844171b2f29703fde08c2e8d1d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page