├── .github ├── dependabot.yml └── workflows │ ├── build.yml │ ├── cd.yaml │ └── template_values.toml ├── CONTRIBUTING.md ├── LICENSE-MIT ├── README.md └── template ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── audit.yml │ ├── cd.yml │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── cargo-generate.toml └── src ├── lib.rs └── main.rs /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | # Check for updates every Monday 6 | schedule: 7 | interval: "weekly" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build Template 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | env: 12 | PROJECT_NAME: rust-gh-example 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v4 16 | - name: Run cargo generate 17 | uses: cargo-generate/cargo-generate-action@v0.20.0 18 | with: 19 | name: ${{ env.PROJECT_NAME }} 20 | template: template 21 | arguments: "--template-values-file .github/workflows/template_values.toml --verbose" 22 | - name: Install Rust toolchain 23 | uses: dtolnay/rust-toolchain@stable 24 | - name: Cargo check 25 | # we need to move the generated project to a temp folder, away from the template project 26 | # otherwise `cargo` runs would fail 27 | # see https://github.com/rust-lang/cargo/issues/9922 28 | run: | 29 | mv $PROJECT_NAME ${{ runner.temp }}/ 30 | cd ${{ runner.temp }}/$PROJECT_NAME 31 | cargo check --tests 32 | -------------------------------------------------------------------------------- /.github/workflows/cd.yaml: -------------------------------------------------------------------------------- 1 | name: Synchronize the example with the template 2 | on: 3 | push: 4 | branches: [main] 5 | 6 | jobs: 7 | synchronize_example: 8 | runs-on: ubuntu-latest 9 | env: 10 | PROJECT_NAME: rust-gh-example 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v4 14 | 15 | - name: Run cargo generate 16 | uses: cargo-generate/cargo-generate-action@v0.20.0 17 | with: 18 | name: ${{ env.PROJECT_NAME }} 19 | template: template 20 | arguments: "--template-values-file .github/workflows/template_values.toml --verbose" 21 | 22 | - name: Generate lockfile 23 | run: | 24 | cd $PROJECT_NAME 25 | cargo generate-lockfile 26 | 27 | - name: Checkout old example 28 | uses: actions/checkout@v4 29 | with: 30 | repository: rust-github/rust-gh-example 31 | path: old_example 32 | ssh-key: ${{ secrets.GH_EXAMPLE_DEPLOY_SECRET }} 33 | 34 | - name: move sources, mit license and Cargo.toml from old to new example 35 | run: | 36 | echo "pwd:" 37 | pwd 38 | echo "ls -al:" 39 | ls -al 40 | rm rust-gh-example/src/main.rs 41 | rm rust-gh-example/Cargo.toml 42 | rm rust-gh-example/LICENSE-MIT 43 | cp old_example/src/* rust-gh-example/src/ 44 | cp old_example/Cargo.toml rust-gh-example/Cargo.toml 45 | cp old_example/LICENSE-MIT rust-gh-example/LICENSE-MIT 46 | - name: update example 47 | run: | 48 | mkdir old_sources 49 | mv old_example/src/* old_sources 50 | cd old_example 51 | rm -rf * .gitignore .github/ 52 | echo "ls ../rust-gh-example:" 53 | ls ../rust-gh-example 54 | echo "ls ../rust-gh-example/src:" 55 | ls ../rust-gh-example/src 56 | mv ../rust-gh-example/* ../rust-gh-example/.github ../rust-gh-example/.gitignore . 57 | echo "ls -al:" 58 | ls -al 59 | rm src/* 60 | mv ../old_sources/* src 61 | - name: commit example 62 | run: | 63 | cd old_example 64 | git config user.name github-actions 65 | git config user.email github-actions@github.com 66 | git add . 67 | if [ -n "$(git status --porcelain)" ]; then 68 | git commit -m "automatic update" -m "from $GITHUB_REPOSITORY@$GITHUB_SHA" 69 | git push 70 | else 71 | echo "nothing to commit"; 72 | fi 73 | -------------------------------------------------------------------------------- /.github/workflows/template_values.toml: -------------------------------------------------------------------------------- 1 | [values] 2 | gh-username = "rust-github" 3 | project-description = "Example of Rust GitHub template" -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | First off, thank you for considering contributing to Rust GitHub Template. 4 | 5 | If your contribution is not straightforward, please first discuss the change you 6 | wish to make by creating a new issue before making the change. 7 | 8 | One of the project goals is to be easy to understand so, especially for github 9 | actions, try to keep things simple and to add comments whenever this is not 10 | possible. 11 | 12 | ## Reporting issues 13 | 14 | Before reporting an issue on the 15 | [issue tracker](https://github.com/rust-github/template/issues), 16 | please check that it has not already been reported by searching for some related 17 | keywords. 18 | 19 | Try to use a clear title, and describe your problem with complete sentences. 20 | 21 | ## Pull requests 22 | 23 | Try to do one pull request per change. 24 | 25 | ## GitHub Actions 26 | 27 | When we have to mix GitHub actions variables with the `{{ }}` liquid syntax, 28 | GitHub actions variables are written in the format 29 | `{{ "{{ github.variable }}" }}` instead of `{{ github.variable }}`. 30 | 31 | See [Continuous delivery](https://github.com/rust-github/template/blob/main/template/.github/workflows/cd.yml) 32 | as an example. 33 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Marco Ieni 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust Github Template 2 | 3 | A template for [cargo generate](https://github.com/cargo-generate/cargo-generate) that aims to be a starting point suitable for 4 | the vast majority of rust projects that will be hosted on GitHub. 5 | 6 | See the project [website](https://rust-github.github.io). -------------------------------------------------------------------------------- /template/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Bug description 11 | 12 | 13 | 14 | - Would you like to work on a fix? [y/n] 15 | 16 | ## To Reproduce 17 | 18 | Steps to reproduce the behavior: 19 | 20 | 1. ... 21 | 2. ... 22 | 3. ... 23 | 4. ... 24 | 25 | 26 | 27 | ## Expected behavior 28 | 29 | 30 | 31 | ## Screenshots 32 | 33 | 34 | 35 | ## Environment 36 | 37 | 38 | 39 | - OS: [e.g. Ubuntu 20.04] 40 | - {{project-name}} version: [e.g. 0.1.0] 41 | 42 | ## Additional context 43 | 44 | 45 | -------------------------------------------------------------------------------- /template/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | -------------------------------------------------------------------------------- /template/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Motivations 11 | 12 | 15 | 16 | - Would you like to implement this feature? [y/n] 17 | 18 | ## Solution 19 | 20 | 21 | 22 | ## Alternatives 23 | 24 | 25 | 26 | ## Additional context 27 | 28 | 29 | -------------------------------------------------------------------------------- /template/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /template/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "cargo" 4 | # Look for `Cargo.toml` and `Cargo.lock` in the root directory 5 | directory: "/" 6 | # Check for updates every Monday 7 | schedule: 8 | interval: "weekly" 9 | open-pull-requests-limit: 10 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | # Check for updates every Monday 13 | schedule: 14 | interval: "weekly" 15 | open-pull-requests-limit: 10 16 | -------------------------------------------------------------------------------- /template/.github/workflows/audit.yml: -------------------------------------------------------------------------------- 1 | name: Security audit 2 | 3 | on: 4 | schedule: 5 | # Runs at 00:00 UTC everyday 6 | - cron: '0 0 * * *' 7 | push: 8 | paths: 9 | - '**/Cargo.toml' 10 | - '**/Cargo.lock' 11 | pull_request: 12 | {% raw %} 13 | jobs: 14 | audit: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | - uses: Swatinem/rust-cache@v2 20 | - name: Run security audit 21 | uses: rustsec/audit-check@v2.0.0 22 | with: 23 | token: ${{ secrets.GITHUB_TOKEN }} 24 | {% endraw %} 25 | -------------------------------------------------------------------------------- /template/.github/workflows/cd.yml: -------------------------------------------------------------------------------- 1 | name: CD # Continuous Deployment 2 | 3 | on: 4 | push: 5 | tags: 6 | - '[v]?[0-9]+.[0-9]+.[0-9]+' 7 | 8 | jobs: 9 | {% if crate_type == "bin" %} 10 | publish: 11 | name: Publishing for {{ "${{ matrix.job.os-name }}" }}-{{ "${{ matrix.job.architecture }}" }} 12 | runs-on: {{ "${{ matrix.job.os }}" }} 13 | permissions: 14 | contents: write 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | rust: [stable] 19 | job: 20 | - os: macos-latest 21 | os-name: macos 22 | target: x86_64-apple-darwin 23 | architecture: x86_64 24 | - os: macos-latest 25 | os-name: macos 26 | target: aarch64-apple-darwin 27 | architecture: arm64 28 | - os: ubuntu-latest 29 | os-name: linux 30 | target: x86_64-unknown-linux-gnu 31 | architecture: x86_64 32 | - os: windows-latest 33 | os-name: windows 34 | target: x86_64-pc-windows-msvc 35 | architecture: x86_64 36 | - os: ubuntu-latest 37 | os-name: linux 38 | target: aarch64-unknown-linux-gnu 39 | architecture: arm64 40 | - os: ubuntu-latest 41 | os-name: linux 42 | target: i686-unknown-linux-gnu 43 | architecture: i686 44 | 45 | steps: 46 | - name: Checkout repository 47 | uses: actions/checkout@v4 48 | - name: Install Rust toolchain 49 | uses: dtolnay/rust-toolchain@stable 50 | with: 51 | toolchain: {{ "${{ matrix.rust }}" }} 52 | target: {{ "${{ matrix.job.target }}" }} 53 | - name: Install cross 54 | uses: taiki-e/install-action@v2 55 | with: 56 | tool: cross 57 | - name: Build release binary 58 | run: cross build --locked --release --target {{ "${{ matrix.job.target }}" }} 59 | 60 | - name: install strip command 61 | if: matrix.job.target == 'aarch64-unknown-linux-gnu' 62 | shell: bash 63 | run: | 64 | sudo apt update 65 | sudo apt-get install -y binutils-aarch64-linux-gnu 66 | - name: Packaging final binary 67 | shell: bash 68 | run: | 69 | BINARY=target/{{ "${{ matrix.job.target }}" }}/release/{{project-name}} 70 | if [[ {{ "${{ runner.os }}" }} == 'Windows' ]]; then 71 | BINARY=$BINARY.exe 72 | fi 73 | 74 | ####### reduce binary size by removing debug symbols ####### 75 | if [[ {{ "${{ matrix.job.target }}" }} == aarch64-unknown-linux-gnu ]]; then 76 | GCC_PREFIX="aarch64-linux-gnu-" 77 | else 78 | GCC_PREFIX="" 79 | fi 80 | "$GCC_PREFIX"strip $BINARY 81 | 82 | ########## create tar.gz ########## 83 | mkdir assets 84 | RELEASE_NAME={{project-name}}-${GITHUB_REF/refs\/tags\//}-{{ "${{ matrix.job.os-name }}" }}-{{ "${{ matrix.job.architecture }}" }} 85 | tar czvf assets/$RELEASE_NAME.tar.gz $BINARY 86 | 87 | ########## create sha256 ########## 88 | if [[ {{ "${{ runner.os }}" }} == 'Windows' ]]; then 89 | certutil -hashfile assets/$RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > assets/$RELEASE_NAME.sha256 90 | else 91 | shasum -a 256 assets/$RELEASE_NAME.tar.gz > assets/$RELEASE_NAME.sha256 92 | fi 93 | - name: Releasing assets 94 | uses: softprops/action-gh-release@v2 95 | with: 96 | files: assets/* 97 | env: 98 | GITHUB_TOKEN: {{ "${{ secrets.GITHUB_TOKEN }}" }} 99 | {% endif %} 100 | publish-cargo: 101 | name: Publishing to Cargo 102 | runs-on: ubuntu-latest 103 | steps: 104 | - name: Checkout repository 105 | uses: actions/checkout@v4 106 | - name: Install Rust toolchain 107 | uses: dtolnay/rust-toolchain@stable 108 | - uses: Swatinem/rust-cache@v2 109 | - run: cargo publish 110 | env: 111 | CARGO_REGISTRY_TOKEN: {{ "${{ secrets.CARGO_REGISTRY_TOKEN }}" }} 112 | -------------------------------------------------------------------------------- /template/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI # Continuous Integration 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | {% raw %} 9 | jobs: 10 | 11 | test: 12 | name: Test Suite 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v4 17 | - name: Install Rust toolchain 18 | uses: dtolnay/rust-toolchain@stable 19 | - uses: Swatinem/rust-cache@v2 20 | - name: Run tests 21 | run: cargo test --all-features --workspace 22 | 23 | rustfmt: 24 | name: Rustfmt 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Checkout repository 28 | uses: actions/checkout@v4 29 | - name: Install Rust toolchain 30 | uses: dtolnay/rust-toolchain@stable 31 | with: 32 | components: rustfmt 33 | - uses: Swatinem/rust-cache@v2 34 | - name: Check formatting 35 | run: cargo fmt --all --check 36 | 37 | clippy: 38 | name: Clippy 39 | runs-on: ubuntu-latest 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v4 43 | - name: Install Rust toolchain 44 | uses: dtolnay/rust-toolchain@stable 45 | with: 46 | components: clippy 47 | - uses: Swatinem/rust-cache@v2 48 | - name: Clippy check 49 | run: cargo clippy --all-targets --all-features --workspace -- -D warnings 50 | 51 | docs: 52 | name: Docs 53 | runs-on: ubuntu-latest 54 | steps: 55 | - name: Checkout repository 56 | uses: actions/checkout@v4 57 | - name: Install Rust toolchain 58 | uses: dtolnay/rust-toolchain@stable 59 | - uses: Swatinem/rust-cache@v2 60 | - name: Check documentation 61 | env: 62 | RUSTDOCFLAGS: -D warnings 63 | run: cargo doc --no-deps --document-private-items --all-features --workspace --examples 64 | {% endraw %} 65 | -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .cargo-ok 3 | .DS_Store 4 | {% if crate_type == "lib" %} 5 | Cargo.lock 6 | {% endif %} -------------------------------------------------------------------------------- /template/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [Unreleased] 8 | -------------------------------------------------------------------------------- /template/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project adheres to the Rust Code of Conduct, which can be found [here](https://www.rust-lang.org/conduct.html). 4 | -------------------------------------------------------------------------------- /template/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution guidelines 2 | 3 | First off, thank you for considering contributing to {{project-name}}. 4 | 5 | If your contribution is not straightforward, please first discuss the change you 6 | wish to make by creating a new issue before making the change. 7 | 8 | ## Reporting issues 9 | 10 | Before reporting an issue on the 11 | [issue tracker](https://github.com/{{gh-username}}/{{project-name}}/issues), 12 | please check that it has not already been reported by searching for some related 13 | keywords. 14 | 15 | ## Pull requests 16 | 17 | Try to do one pull request per change. 18 | 19 | ### Updating the changelog 20 | 21 | Update the changes you have made in 22 | [CHANGELOG](https://github.com/{{gh-username}}/{{project-name}}/blob/main/CHANGELOG.md) 23 | file under the **Unreleased** section. 24 | 25 | Add the changes of your pull request to one of the following subsections, 26 | depending on the types of changes defined by 27 | [Keep a changelog](https://keepachangelog.com/en/1.0.0/): 28 | 29 | - `Added` for new features. 30 | - `Changed` for changes in existing functionality. 31 | - `Deprecated` for soon-to-be removed features. 32 | - `Removed` for now removed features. 33 | - `Fixed` for any bug fixes. 34 | - `Security` in case of vulnerabilities. 35 | 36 | If the required subsection does not exist yet under **Unreleased**, create it! 37 | 38 | ## Developing 39 | 40 | ### Set up 41 | 42 | This is no different than other Rust projects. 43 | 44 | ```shell 45 | git clone https://github.com/{{gh-username}}/{{project-name}} 46 | cd {{project-name}} 47 | cargo test 48 | ``` 49 | 50 | ### Useful Commands 51 | {% if crate_type == "bin" %} 52 | - Build and run release version: 53 | 54 | ```shell 55 | cargo build --release && cargo run --release 56 | ``` 57 | {% endif %} 58 | - Run Clippy: 59 | 60 | ```shell 61 | cargo clippy --all-targets --all-features --workspace 62 | ``` 63 | 64 | - Run all tests: 65 | 66 | ```shell 67 | cargo test --all-features --workspace 68 | ``` 69 | 70 | - Check to see if there are code formatting issues 71 | 72 | ```shell 73 | cargo fmt --all -- --check 74 | ``` 75 | 76 | - Format the code in the project 77 | 78 | ```shell 79 | cargo fmt --all 80 | ``` 81 | -------------------------------------------------------------------------------- /template/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "{{project-name}}" 3 | version = "0.1.0" 4 | edition = "2021" 5 | description = "{{project-description}}" 6 | repository = "https://github.com/{{gh-username}}/{{project-name}}" 7 | license = "MIT OR Apache-2.0" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | -------------------------------------------------------------------------------- /template/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /template/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 {{authors}} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # {{project-name}} 2 | 3 | [![Crates.io](https://img.shields.io/crates/v/{{project-name}}.svg)](https://crates.io/crates/{{project-name}}) 4 | [![Docs.rs](https://docs.rs/{{project-name}}/badge.svg)](https://docs.rs/{{project-name}}) 5 | [![CI](https://github.com/{{gh-username}}/{{project-name}}/workflows/CI/badge.svg)](https://github.com/{{gh-username}}/{{project-name}}/actions) 6 | 7 | ## Installation 8 | 9 | ### Cargo 10 | 11 | * Install the rust toolchain in order to have cargo installed by following 12 | [this](https://www.rust-lang.org/tools/install) guide. 13 | * run `cargo install {{project-name}}` 14 | 15 | ## License 16 | 17 | Licensed under either of 18 | 19 | * Apache License, Version 2.0 20 | ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 21 | * MIT license 22 | ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 23 | 24 | at your option. 25 | 26 | ## Contribution 27 | 28 | Unless you explicitly state otherwise, any contribution intentionally submitted 29 | for inclusion in the work by you, as defined in the Apache-2.0 license, shall be 30 | dual licensed as above, without any additional terms or conditions. 31 | 32 | See [CONTRIBUTING.md](CONTRIBUTING.md). 33 | -------------------------------------------------------------------------------- /template/cargo-generate.toml: -------------------------------------------------------------------------------- 1 | [template] 2 | cargo_generate_version = ">=0.10.0" 3 | 4 | [placeholders.gh-username] 5 | type = "string" 6 | prompt = "GitHub username (or organization)" 7 | # The username cannot end with a hyphen, too, but 8 | # this requirement is not captured by the regex at the moment. 9 | regex = "^[A-Za-z0-9][A-Za-z0-9-]{0,38}$" 10 | 11 | [placeholders.project-description] 12 | type = "string" 13 | prompt = "Project description" 14 | 15 | [conditional.'crate_type == "lib"'] 16 | ignore = [ "src/main.rs" ] 17 | 18 | [conditional.'crate_type == "bin"'] 19 | ignore = [ "src/lib.rs" ] 20 | -------------------------------------------------------------------------------- /template/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /template/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | --------------------------------------------------------------------------------