Skip to main content

ican is a simple version bumper/build pipeline orchestrator

Project description

build, publish, and release Code style: black PyPI version CodeFactor MIT license GitHub last commit GitHub repo size GitHub language count GitHub top language Whos your daddy works badge

:wave: ican

Because anything you ask of it, the response is always ican.

:man_office_worker: Motivation

There are plenty of version bumpers and build tools. But ican is the only one that is designed for the smallest teams, even the 1 man team.

The one man team has different procedures than most. Often times the one man team forgets to bump version numbers. Few even bother to keep a code repository besides their own "Dropbox."

ican brings big team development practices to small teams. ican's build number is one feature. As long as you use ican to automate your docker image builds, deployments, etc. each time your build number is incremented. That way you always have a different semantic version number, even if you don't purposely bump one of the primary 3 parts.

You can even easily use ican to start tagging docker images, as well as git commits. Soon your small team will be officially "tagging" and "releasing" software like you have a Fortune 500 CI/CD manager.

:floppy_disk: Install

Install the ican package via pypi

pip install ican

:toolbox: Sample Config

Config is done via the .ican file in your project's root diarectory.

Sample .ican config file

current = 0.1.6+build.40
previous = 0.1.5+build.39

log_file = ican.log

[file: version]
file = ./src/
style = semantic
variable = __version__

[pipeline: release]
step1 = ./
step2 = $ICAN(bump {arg_1})
step2 = git commit -a
step3 = git tag -a {tag} --sign
step4 = git push origin master {tag}


  • This config defines the current version as 0.1.6 with build # 40.
  • All operations will be logged to the ican.log file.
  • ican will update a variable named __version__ in ./src/ any time the bump command is run.
  • ican will use the semantic style of the version when updating this file.
  • A release pipeline has been defined. More on that later.

:exclamation: Important

Take note, all sections must be unique. So if you define more than one [file: [LABEL]] section, make sure each one has a unique label.

:thumbsdown: :exploding_head:

[file: py_code]
file = ./src/
[file: py_code]
file = ./src/

:thumbsup: :sunglasses:

[file: src_init]
file = ./src/
[file: main]
file = ./src/

:triangular_ruler: Config

Section Key Value
version current This is the value that ican stores the current version number in.
version previous This is the previous version ican uses in case of rollback.
options log_file All operations are logged to disk in this file. To turn logging off, do not define the log_file.
aliases [ALIAS] Built-in command + args that [ALIAS] will trigger. Example bump patch
file: [LABEL] file The filename of a file ican will update with new versions. You can use a standard unix glob (*.py) if desired.
file: [LABEL] style The version format to use. Choices are [semantic, public, pep440, git]
file: [LABEL] variable The variable name pointing to the version string that ican will update when versions are bumped.
file: [LABEL] regex User-supplied python formattted regex string defining how to replace the file's version.
pipeline: [LABEL] [STEP] A pipeline step is a cli command such as git commit -a. STEP values MUST to be unique.

:mag: User-supplied regex

When searching for a variable, ican will search for the variable's name, followed by an = symbol, followed by a value in either single or double quotes. There can be spaces or no spaces on either side of the = symbol. This covers most use cases.

If your use case is more complicated, you can omit the variable line in your config file and instead include a regex value instead. This should be a pyton formatted regex string with a named group to identify the version ican will replace.

file = ./src/
style = semantic
regex = __version__\s*=\s*(?P<quote>[\'\"])(?P<version>.+)(?P=quote)

:computer: Pipelines

Pipeline Intro

Pipelines allow you to define cli commands as well as internal ican functions to be run in a batch. They are defined inside your .ican file.


[pipeline: release]
step1 = $ICAN(bump {arg_1})
step2 = git add .
step3 = git commit -m "auto-commit for {tag}"
step4 = git tag -a {tag} -m "automated tag for release {tag}" --sign
step5 = git push origin master
step6 = $ICAN(show)

You could explicitly tell ican to run the release pipeline with the following command:

  • ican run release patch

  • Step1 uses the variable arg_1. {arg_1} references the first user supplied argument.

  • In the example above, patch is the value assigned to {arg_1}

  • ican allows you to leave out run and simply type: ican release patch

  • Finally, if you do not supply an argument, ican will use the function's default. The bump default is build. The following command will bump build instead of patch before commiting to git.

    • ican release

:exclamation: Important

Each [pipeline: LABEL] needs a unique LABEL value. Pipeline steps in the same pipeline must be unique as well.

:thumbsdown: :exploding_head:

[pipeline: hello]
step1 = echo 'hello world'
[pipeline: hello]
step1 = echo 'this is another pipeline'
step1 = echo 'this example HAS 2 ISSUES'
step1 = echo 'can you spot them?'

:thumbsup: :sunglasses:

[pipeline: hello]
step1 = echo 'hello world'
[pipeline: another]
step1 = echo 'this is another pipeline with a unique label'
step2 = echo 'this example has unique step names within each pipeline'
step3 = Batter.home_run()

Pipeline Context

The pipeline context is available in 2 locations

  • You can template your pipeline steps, using the {variable_name} format. Example: git push origin master {tag}
  • Before a pipeline runs, ican will inject your shell's environment with all pipeline context variables prefixed with ICAN_.

For example you can access semantic in your ENV as ICAN_SEMANTIC

Pipeline Context Variables

variable Description
semantic the current version in semantic format
public the current version in public format
pep440 the current version canonical with pep440
git the current version using git metadata
major the major portion of the semantic version
minor the minor portion of the semantic version
patch the patch portion of the semantic version
prerelease the major portion of the semantic version
build the build number
tag the git tag, v{public_version}
age REBUILD if bump build, NEW all other bumps
env DEVELOPMENT or PRODUCTION based on the version
root the root directory of your project
previous the previous semantic version

:muscle: Use

You can use ican via the CLI in a typical fashion, using the format below

ican [command] [arguments] [options]

:dog2: Commands

Command Arguments Options Description
bump PART required Increments the PART of the semantic version.
[major, minor, patch, prerelease]
bump --pre TOKEN If bumping prerelease, set the TOKEN to [alpha, beta, rc, dev]
pre TOKEN required Set the prerelease TOKEN without bumping.
show STYLE required Shows the current version with the format STYLE.
[semantic, public, pep440, git]
run PIPELINE required Run the specified PIPELINE
rollback none Rollback to the previously persisted version.
init none Initialize your project with default config in the current directory.

:roll_eyes: Options

The output and parsing of ican can be controlled with the following options.

Name Description
--verbose To aid in your debugging, verbose prints all messages.
--dry-run Useful if used WITH --verbose, will not modify any files.
--version This will displpay the current version of ican.

:eyes: Examples

$ ican init


$ ican show current

# Bump with no arguments defaults to bump the build number.
$ ican bump

# Now its release time.  Lets bump the minor
$ ican bump minor

# Oh no, major problem, rollback
$ ican rollback

# Use an aliaw
$ ican deploy
git commit successful

# now run our docker pipeline
$ ican run docker
+BEGIN pipeline.DOCKER
docker container build...
+END pipeline.DOCKER

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ican-0.1.41.tar.gz (39.7 kB view hashes)

Uploaded source

Built Distribution

ican-0.1.41-py3-none-any.whl (38.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page