Skip to content

Commit

Permalink
feat(basic): Add workspace flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bengreenier committed Oct 29, 2021
1 parent 716a305 commit 914a396
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -24,8 +24,9 @@ jobs:
version: ["0.1.0"]
description: ["desc"]
gh_account: ["bengreenier"]
workspace: [true, false]
env:
NAME: ${{ format('{0}-{1}', matrix.template, matrix.type) }}
NAME: ${{ format('{0}-{1}-{2}', matrix.template, matrix.type, matrix.workspace) }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -36,14 +37,15 @@ jobs:
with:
name: ${{ env.NAME }}
subfolder: ${{ matrix.template }}
other: ${{ format('--{0} --define version={1} --define description={2} --define gh-account={3}', matrix.type, matrix.version, matrix.description, matrix.gh_account) }}
other: ${{ format('--{0} --define version={1} --define description={2} --define gh-account={3} --define workspace={4}', matrix.type, matrix.version, matrix.description, matrix.gh_account, matrix.workspace) }}
# 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
- name: "validate scaffolded project"
run: |
exit 1
mv ${{ env.NAME }} ${{ runner.temp }}/
cd ${{ runner.temp }}/${{ env.NAME }}
cargo install just
Expand Down
5 changes: 5 additions & 0 deletions basic/Cargo.toml
Expand Up @@ -8,3 +8,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

{% if workspace %}
[workspace]
members = []
{% endif %}
1 change: 1 addition & 0 deletions basic/cargo-generate.toml
Expand Up @@ -5,6 +5,7 @@ cargo_generate_version = ">=0.10.1"
gh-account = {type = "string", prompt = "What GitHub account will own this project?"}
description = { type = "string", prompt = "Describe this crate" }
version = {type = "string", prompt = "What's the starting version?", default = "0.1.0"}
workspace = {type = "bool", prompt = "Is this a workspace with a root crate?", default = false}

[conditional.'crate_type == "lib"']
ignore = ["src/main.rs"]
Expand Down

0 comments on commit 914a396

Please sign in to comment.