diff --git a/.idea/runConfigurations/version_auto___git.xml b/.idea/runConfigurations/version_auto___git.xml index 45d55633786e4faee54a87323fe632077a34249a..ca30067ff1e5bed37aef4ee08ce54ba151f730ae 100644 --- a/.idea/runConfigurations/version_auto___git.xml +++ b/.idea/runConfigurations/version_auto___git.xml @@ -1,7 +1,7 @@ <component name="ProjectRunConfigurationManager"> <configuration default="false" name="version auto --git" type="GoApplicationRunConfiguration" factoryName="Go Application"> <module name="version" /> - <working_directory value="$PROJECT_DIR$" /> + <working_directory value="$PROJECT_DIR$/../../alvine/components/alvine.dispatcher" /> <parameters value="auto --git" /> <EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.GolandRunConfigurationExtension"> <option name="DIRENV_ENABLED" value="false" /> diff --git a/.idea/version.iml b/.idea/version.iml index e03d8ecfb9d940ecf515056b738acafa6c313055..c9286c2cbb9ce02976902cd77fbeed9498269880 100644 --- a/.idea/version.iml +++ b/.idea/version.iml @@ -7,6 +7,7 @@ <excludeFolder url="file://$MODULE_DIR$/.devenv" /> <excludeFolder url="file://$MODULE_DIR$/.direnv" /> <excludeFolder url="file://$MODULE_DIR$/build" /> + <excludeFolder url="file://$MODULE_DIR$/.task" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> diff --git a/README.md b/README.md index cb3c00635a61d482b5864fa742aca7ac0f5e3adf..ec369c210dc2fe1e52dd1d2915e15ef4f3dd6178 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,15 @@ It is important to note that this feature requires that your commit messages follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) message format. +The `exit-code-if-no-bump` flag can be used to make the command exit with a non-zero exit. +This is useful for CI/CD pipelines. + +```bash +version auto --exit-code-if-no-bump +``` + +In this case, the command will exit with the exit code 1 if no version bump is required. + **Predict** The `predict` command allows you to predict the next version based on the diff --git a/source/commandline.go b/source/commandline.go index fb8736c59ac9b75ad1f556a470685bc7cac5d07f..6acbb6256db18c29a285bc2760337419a735ff4f 100644 --- a/source/commandline.go +++ b/source/commandline.go @@ -31,6 +31,7 @@ type commandLineOptions struct { Date struct { } `command:"date" description:"print the current date and time in the format YYYYMMDDHHMMSS"` Auto struct { + ExitCode bool `short:"e" long:"exit-code-if-no-bump" description:"exit code to use if no notable changes are found" default:"0"` } `command:"auto" description:"check the git repository and increase the version if necessary. This implies --git"` Predict struct { } `command:"predict" description:"predict the next version based on the git history. This implies --git"` @@ -178,7 +179,13 @@ func executeCommand() { case OtherCommit: fmt.Println("No notable changes found.") fmt.Println("If you want to force a version\nincrease, use the major, minor\nor patch command.") - os.Exit(0) + + exitCode := 0 + if arguments.Auto.ExitCode { + exitCode = 1 + } + + os.Exit(exitCode) } }