Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(single_crate): Add single_crate
- Loading branch information
1 parent
181aa56
commit f87c703
Showing
11 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-18.04 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This is a basic workflow to ensure code builds and passes tests. | ||
|
||
name: CI | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on pull_request but only when the target is the main branch | ||
pull_request: | ||
branches: [ main ] | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checkout our code | ||
- uses: actions/checkout@v2 | ||
# Install Just, so we can use our Justfile in the action | ||
- run: cargo install just | ||
# Install necessary tools | ||
- run: just install-tools | ||
# Check our code | ||
- run: just check | ||
# Run tests | ||
- run: just test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This is a basic workflow to generate release artifacts for rust projects | ||
# It requires a [Repository secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) | ||
# For `cargo publish` that can be obtained [here](https://crates.io/me) | ||
# CARGO_REGISTRY_TOKEN: <your_token> | ||
|
||
name: Release | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push but only for the main branch | ||
push: | ||
branches: [main] | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "release" | ||
release: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Use `release-please` to track changes and generate release PRs | ||
- uses: GoogleCloudPlatform/release-please-action@v2 | ||
id: release | ||
with: | ||
release-type: rust | ||
# The name of your crate | ||
package-name: "{{ crate_name }}" | ||
# The logic below handles the crates.io publication: | ||
- uses: actions/checkout@v2 | ||
# these if statements ensure that a publication only occurs when | ||
# a new release is created: | ||
if: ${{ steps.release.outputs.release_created }} | ||
# Install Just, so we can use our Justfile in the action | ||
- run: cargo install just | ||
if: ${{ steps.release.outputs.release_created }} | ||
# Install necessary tools | ||
- run: just install-tools | ||
if: ${{ steps.release.outputs.release_created }} | ||
# Check our code | ||
- run: just check | ||
if: ${{ steps.release.outputs.release_created }} | ||
# Run tests | ||
- run: just test | ||
if: ${{ steps.release.outputs.release_created }} | ||
# Publish the crate (note: release-please will have updated the Cargo.toml for us, so it should already have the correct version) | ||
- run: just publish | ||
if: ${{ steps.release.outputs.release_created }} | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
|
||
{% if crate_type == "lib" %} | ||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
{% endif %} | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "{{crate_name}}" | ||
description = "{{description}}" | ||
license = "mit" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# You'll need just to get started: `cargo install just` | ||
# just manual: https://github.com/casey/just/#readme | ||
|
||
_default: | ||
@just --list | ||
|
||
# Installs tools needed for other `just` recipes | ||
install-tools: | ||
cargo install cargo-hack cargo-bump | ||
|
||
# Checks (using `clippy`) all crates across all features | ||
check: | ||
cargo hack --feature-powerset --exclude-no-default-features clippy --locked -- -D warnings | ||
|
||
# Tests all crates across all features | ||
test: | ||
cargo hack --feature-powerset --exclude-no-default-features test --locked | ||
|
||
# Sets the version of the crate to `version` | ||
set-version version: | ||
cargo bump {{version}} | ||
|
||
# Attempts to publish the crate using `cargo` | ||
publish: | ||
cargo publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 {{authors}} | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# {{project-name}} | ||
|
||
[![CI](https://github.com/{{authors}}/{{project_name}}/actions/workflows/ci.yml/badge.svg)](https://github.com/{{authors}}/{{project_name}}/actions/workflows/ci.yml) | ||
[![Crates.io](https://img.shields.io/crates/d/{{project_name}})](https://crates.io/crates/{{project_name}}) | ||
[![docs.rs](https://img.shields.io/docsrs/{{project_name}})](https://docs.rs/{{project_name}}) | ||
|
||
{{description}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[template] | ||
cargo_generate_version = "0.10.3" | ||
|
||
[placeholders] | ||
description = { type = "string", prompt = "Describe this crate:" } | ||
version = {type = "string", prompt = "What's the starting version?", default = "0.1.0"} | ||
|
||
[conditional.'crate_type == "lib"'] | ||
ignore = ["src/main.rs"] | ||
|
||
[conditional.'crate_type == "bin"'] | ||
ignore = ["src/lib.rs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |