diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 95eee12..91d3b9b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ jobs: run: | mkdir -p target/x86_64-unknown-linux-musl/release/ docker build . --file Dockerfile --tag crom - docker run --name crom crom + docker run --name crom crom help docker cp crom:/usr/bin/crom target/x86_64-unknown-linux-musl/release/crom docker rm crom - name: Upload Artifacts @@ -49,7 +49,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: run - args: -- update-version --pre-release release + args: -- write-version next-release - uses: actions-rs/cargo@v1 with: command: check @@ -81,7 +81,7 @@ jobs: - name: Create release run: | chmod +x artifacts/linux/crom - artifacts/linux/crom tag next-release --local --github --ignore-changes + artifacts/linux/crom tag next-release --local --github artifacts/linux/crom upload latest --artifact-path=./artifacts linux mac env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 786ab02..afe2d07 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Image you have a few released version like below. When you run `crom get latest` and there are no working changes, you see `v0.1.4`. -You start working on awesome feature #4 and yor run `crom get latest` when your git history looks like: +You start working on awesome feature #4 and yor run `crom get pre-release` when your git history looks like: ``` * 0cc81e3 - Adding awesome feature #4 @@ -32,13 +32,13 @@ You start working on awesome feature #4 and yor run `crom get latest` when your * 557f909 - (tag: v0.1.2) Adding awesome feature #1 ``` -Crom will tell you the version is `v0.1.5-{short git hash}` since there are local changes, and `v0.1.5` hasn't been released yet. +Crom will tell you the version is `v0.1.5-0cc81e3` since there are local changes, and `v0.1.5` hasn't been released yet. Now lets push to the repo. CI kicks off, instead of having to update a config file with every version you run `crom write-version next-release`. This will update your version meta-data to be `v0.1.5`. Now you run your build. As the build executes and your code isn't to blame, but you need to fix something. -After fixing the change, you re-run `crom get latest` and still see `v0.1.5-SNAPSHOT` since you don't release if a version doesn't build. +After fixing the change, you re-run `crom get latest` and still see `v0.1.4` since you don't release if a version doesn't build. When you push, the history looks like: @@ -50,9 +50,11 @@ When you push, the history looks like: * 557f909 - (tag: v0.1.2) Adding awesome feature #1 ``` -The CI job runs again, running `crom update-version --pre-release release` like before, and getting `v0.1.5` like before. This time however, the build passes. +The CI job runs again, running `crom write-version next-release` like before, and getting `v0.1.5` like before. This time however, the build passes. -Since the job passed, you want to tag it with `crom tag-version --source local,github --ignore-changes`. This creates a tag locally, and on GitHub. The tag locally is so you can use `crom upload-artifacts` without specifying a version. +Since the job passed, you want to tag it with `crom tag next-release --local --github`. This creates a tag locally, and on GitHub. Now that the release has been created, +you may want to upload artifacts that were produced. To upload the artifacts you run `crom upload latest foo bar biz` where the artifacts are named `foo`, `bar`, `biz` in +`.crom.toml`. Now on your local machine you run `git fetch && git pull` and see the history now looks like: @@ -64,7 +66,7 @@ Now on your local machine you run `git fetch && git pull` and see the history no * 557f909 - (tag: v0.1.2) Adding awesome feature #1 ``` -Running `crom get current-version` shows `v0.1.5`. +Running `crom get latest` shows `v0.1.5`. ## Config Options Here is an example `.crom.toml`. diff --git a/src/cli.rs b/src/cli.rs index 05bec85..551b0ea 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,8 @@ -use clap::Clap; +use clap::{ArgGroup, Clap}; use log::LevelFilter; #[derive(Clap, Debug)] +#[clap(group = ArgGroup::new("logging"))] pub struct LoggingOpts { /// A level of verbosity, and can be used multiple times #[clap(short, long, parse(from_occurrences), global(true), group = "logging")] @@ -194,32 +195,35 @@ impl TagSubCommand { } #[derive(Clap, Debug)] +#[clap(group = ArgGroup::new("target").required(true).multiple(true))] pub struct TagSubCommandArgs { /// Token to be used when talking to GitHub #[clap(long, env = "GITHUB_TOKEN")] pub github_token: Option, /// Should the tag be created on GitHub - #[clap(short, long, requires = "github-token")] + #[clap(short, long, group = "target", requires = "github-token")] pub github: bool, /// Should the tag be created locally? - #[clap(short, long)] + #[clap(short, long, group = "target")] pub local: bool, } #[derive(Clap, Debug)] -pub struct TagSubCommandCustomArgs { - /// Should the tag be created on GitHub - #[clap(short, long, requires = "github-token")] - pub github: bool, +#[clap(group = ArgGroup::new("target").required(true).multiple(true))] +pub struct TagSubCommandCustomArgs { /// Token to be used when talking to GitHub #[clap(long, env = "GITHUB_TOKEN")] pub github_token: Option, + /// Should the tag be created on GitHub + #[clap(short, long, group = "target", requires = "github-token")] + pub github: bool, + /// Should the tag be created locally? - #[clap(short, long)] + #[clap(short, long, group = "target")] pub local: bool, /// The custom version to be created.