Skip to content

Commit

Permalink
Merge pull request #145 from ethankhall/ethankhall/update-cli
Browse files Browse the repository at this point in the history
update docs and tag interface
  • Loading branch information
ethankhall authored Jan 24, 2021
2 parents c2aa9e9 + b79db03 commit 362cd45
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand All @@ -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:

Expand All @@ -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`.
Expand Down
20 changes: 12 additions & 8 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down Expand Up @@ -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<String>,

/// 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<String>,

/// 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.
Expand Down

0 comments on commit 362cd45

Please sign in to comment.