Skip to content

Commit

Permalink
feat(init): Add initial scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
bengreenier committed Oct 28, 2021
1 parent 77432ac commit 9efd7ce
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
1 change: 1 addition & 0 deletions .actrc
@@ -0,0 +1 @@
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-18.04
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,48 @@
# This is a basic workflow to ensure the templates scaffold, build, and pass tests.

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on pull_request and push but only when the target is the main branch
pull_request:
branches: [main]
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 "build"
validate_template:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
template: ["single_crate", "workspace"]
type: ["lib", "bin"]
version: ["0.1.0"]
description: ["validation test project"]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checkout our code
- uses: actions/checkout@v2
# Use the official generate action to scaffold
- uses: cargo-generate/cargo-generate-action@v0.10.1
with:
name: ${{ format('{0}_{1}', matrix.template, matrix.type) }}
subfolder: ${{ matrix.template }}
other: ${{ format('--{0} --define version={1} --define description={2}', matrix.type, matrix.version, matrix.description) }}
# we need to move the generated project to a temp folder, away from the template project
# otherwise `cargo` runs would fail
# see https://github.com/rust-lang/cargo/issues/9922
#
# Then we install tools, and use `just test` to confirm things work
- run: |
mv $PROJECT_NAME ${{ runner.temp }}/
cd ${{ runner.temp }}/$PROJECT_NAME
cargo install just
just install-tools
just test
37 changes: 36 additions & 1 deletion README.md
@@ -1,2 +1,37 @@
# rust-templates
Templates for creating rust projects with a GitHub-managed lifecycle with cargo-generate πŸ—οΈπŸ“ƒ

Templates for creating rust projects with a GitHub-managed lifecycle with cargo-generate. πŸ—οΈπŸ“ƒ

What you get:

- PR build validation
- Automated Release PR generation using [release-please](https://github.com/googleapis/release-please)
- Automated crates.io publishing (after merging a Release PR)

## Quickstart

> First make sure you've done: `cargo install cargo-generate`.
### single_crate

> Use this template for single crate repositories.
```
cargo generate bengreenier/rust-templates.git single_crate
```

### workspace

> Use this template for [rust workspace](https://doc.rust-lang.org/cargo/reference/workspaces.html) projects that will produce multiple crates.
```
cargo generate bengreenier/rust-templates.git workspace
```

## Favorites

If you use these templates repeatedly, be sure to [favorite them](https://crates.io/crates/cargo-generate#favorites) for quicker access!

## Supporting the project

If this project saved you some time, and you'd like to see it continue to be invested in, consider [buying me a coffee. β˜•](https://www.buymeacoffee.com/bengreenier)

0 comments on commit 9efd7ce

Please sign in to comment.