A github rust workflows template, just want to focus on coding.
- Directly create your Github repository
- Fast generate template with GitHub Actions
- Support cargo-generate
- Based on conventional commits
- Based on push vTag
- Bumps Crate version
- Create GitHub tag
- 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
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!
If need directly create your Github repository, in addition to all the above steps, you also need:
-
Creating a fine-grained personal access token.
Repository access:
All repositories
Permissions > Repository permissions:
Administration
Contents
Workflows
> Access:Read and write
-
Copy personal access token.
-
Creating encrypted secrets for a repository.
Name field:
PAT_ADMIN_CODE_WORKFLOWS
# 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
Field | Type | Default | Description |
---|---|---|---|
crate-name | string | required | Package name |
crate-type | bin or lib | bin | Linkage |
owner | string | required | Owner, for filling README and LICENSE and note Cargo.toml |
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 |
Workflows of bin
can be view:
- workflow file
- on push and pull request summary
- release please PR
- automatic release summary
- automatic release assets
- manually release summary
- manually release assets
Workflows of lib
can be view:
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 tag
- Generate Changelog
We run the following command to complete continuous integration:
cargo test
cargo fmt
cargo clippy
When the ci passed, we build statically linked binaries under the following targets and upload the artifacts:
You can modify it as you like, but you need to pay attention to some extra steps for some target.
rust-template/template/.github/workflows/cicd.yaml
Lines 89 to 103 in 7b8fe91
When the build passed, we download 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
rust-template is licensed under either of the following, at your option: