Skip to content

Command Line Tool for release workflow automation.

License

Notifications You must be signed in to change notification settings

mercedes-benz/gitflow-cli

Repository files navigation

Gitflow-CLI

build blackduck

Gitflow is a branching model that organizes feature development, releases, and hotfixes into dedicated branches, providing a structured approach to managing complex software projects with reliable releases based on semantic versioning.

The gitflow-cli automates this release workflow process, saving time and reducing the risk of errors. It maintains a clean and consistent Git graph, contributing to overall project stability.

gitflow-cli-demo

Installation

From within the project directory the gitflow-cli can be built, run and installed.

  1. Clone the repository:

    git clone https://github.com/mercedes-benz/gitflow-cli.git
    cd gitflow-cli
  2. Install the application:

    To install and run the application, use the following commands:

    go install
    gitflow-cli --help

    Note: Make sure you have Go installed and that the go/bin directory is part of your PATH.

Usage

Before starting to use gitflow-cli, navigate to the Git repository you want to operate on. Make sure the repository meets all preconditions.

Release:

To initiate a new release/x.y.z branch from develop, use the following command:

gitflow-cli release start

You can now use the release/x.y.z branch for bug fixing, creating the release changelog, or even deploying your product on a staging environment. Once the release is ready, finish it with:

gitflow-cli release finish

Hotfix:

To initiate a new hotfix/x.y.z branch from main, use the following command:

gitflow-cli hotfix start

Check out the hotfix/x.y.z branch, create a quick patch, and push your changes. Then, finish the hotfix with:

gitflow-cli hotfix finish

Preconditions

To use gitflow-cli, ensure your project meets the basic structural requirements, particularly around Git branches and version management.

Git Branches

Your repository must define a dedicated production and development branches (e.g. main and develop). These can be customized as needed.

Version File

Each project type may store version information in a different location. The gitflow-cli detects your project's context and automatically delegates tasks to the appropriate plugin based on the presence of specific files.

Available Plugins

Plugin Description Required File Status
standard Plugin for projects without a predefined technology stack. version.txt implemented
maven Plugin for maven projects. pom.xml implemented
npm Plugin for npm projects. package.json planned

Configuration

You have the option to provide a configuration file to gitflow-cli. This configuration file will be automatically located at HOME/.gitflow-cli.yaml and has the following structure:

core:
  production: main | custom-name                        # production branch name
  development: develop | custom-name                    # development branch name
  release: release | custom-name                        # release branch prefix
  hotfix: hotfix | custom-name                          # hotfix branch prefix
  undo: true | false                                    # rollback local changes in case of an error, default = false
  logging: stderr | stdout | cmdline | output | off     # diagnostic logging for the Gitflow workflow, default = stdout | cmdline | output

You can also specify a custom configuration file using the top-level flag --config file-path.

Contributing

We welcome any contributions. If you want to contribute to this project, please read the contributing guide.

Git Hook

To contribute to gitflow-cli, we suggest setting up the Git hook below to comply with our contribution guidelines.

cp .githooks/prepare-commit-msg .git/hooks/
chmod +x .git/hooks/prepare-commit-msg

Code of Conduct

Please read our Code of Conduct as it is our base for interaction.

License

This project is licensed under the MIT LICENSE.

Provider Information

Please visit https://www.mercedes-benz-techinnovation.com/en/imprint/ for information on the provider.

Notice: Before you use the program in productive use, please take all necessary precautions, e.g. testing and verifying the program with regard to your specific use. The source code has been tested solely for our own use cases, which might differ from yours.