rust-template
A github rust workflows template, just want to focus on coding.
Table of contents
Features
- Fast generate template with GitHub Actions and caching
- Support cargo-generate
- ??Directly create your Github repository??
Template
- Based on conventional commits
- Based on push vTag
- Bumps Crate version
- Create GitHub tags
- Generate CHANGELOG
- Continuous integration with caching
- Cross-platform static compilation
- Upload artifact
- Publish to Crates
- Publish to Docker hub
- Publish to Github releases
- contrib.rocks
- starcharts
Usage
Use GitHub actions
This will not affect your Github, give it a try:
- Use this template.
- Under your repository name, click
Actions
. - In the left sidebar, click the
Generate
. - Above the list of workflow runs, click the Run workflow button.
- When all work is done, at the bottom of the workflow summary page, download template artifacts.
- Enjoy!
When running for the first time, the cache needs to be created. Next time, soon.
Use cargo-generate
# bin
cargo generate --git https://github.com/uplau/rust-template ./template --name "crate-name" --bin
# lib
cargo generate --git https://github.com/uplau/rust-template ./template --name "crate-name" --lib
Template options
Field | Type | Default | Description |
---|---|---|---|
crate-name | string | required | Package name |
crate-type | bin or lib | bin | Linkage |
gh-username | string | required | GitHub username (or organization), for filling LICENSE |
copyright-year | string | 2023 | Copyright year, for filling LICENSE |
use-badge | bool | true | Insert status badge to README top |
use-contrib-rocks | bool | false | Insert contrib.rocks to README#Contributors |
use-deps | bool | true | Insert commonly use deps to Cargo.toml |
use-rust-template | bool | true | Insert rust-template to README#Contributing |
Template workflows
This document is not exhaustive, see
The workflows of bin
can be view summary here, view file here.
The workflows of lib
can be view summary here, view file here.
jobs.release_please
only_bin
We use Release Please parses your git history, looking for conventional commits, and creating release PRs to:
You need allow GitHub Actions to create and approve pull requests, setting can be managed by admins in organization settings under Actions > General > Workflow permissions.
- Bumps Crate version
- Create GitHub tags
- Generate CHANGELOG
jobs.ci
We run the following command to complete continuous integration:
cargo test
cargo fmt
cargo clippy
jobs.build
only_bin
When ci is passed, we build under the following targets:
static_link
64bit
macOS
Linux
Windows
jobs.*_release
only_bin
When the build passes, we upload the artifacts and publish to Github releases, which you can download at any time at the bottom of the workflow summary page:
manually_release
: Triggered byworkflow_dispatch
automatic_release
: Triggered byrelease_please
Contributors
License
rust-template is licensed under either of the following, at your option: