Skip to main content

A command-line utility for easy and reliable management of manual deployments from Git repositories

Project description

simple-git-deploy

Latest tag

A command-line utility for easy and reliable management of manual deployments from Git repositories.

Even manual deployments can be made reliable if some minimal automation is applied. This utility performs atomic deployments from a Git repository, with an optional build phase (e.g. installing dependencies). The previous deployment is not affected until the build completes successfully – no more inconsistency errors when you update your Git branch but your application is not yet fully updated – e.g. missing new dependencies from your package manager.

Each deployment is built in a new directory made just for that deployment. Previous deployments are kept (and can be later purged), and the target is only updated when the build completes – that’s what we meant by atomic! If the build fails, the target will not be updated.

The meaning of build is defined by the user; it can be any command runnable from a shell. Configuration is made in a simple .ini file.

Installation

Requirements:

  • Python ≥ 3.5 (has been tested with 3.6 and 3.7 but should work with 3.5 nonetheless)
  • Git ≥ 2.7 (depends on the git worktree feature)

Install via pip:

$ pip install git+https://github.com/edudobay/simple-git-deploy.git

If this fails and you have no idea what to do, you can try adding the --user option after pip install and before the URL.

Usage

After installing this utility, you can run simple-git-deploy --help for basic usage instructions.

The easiest way is to run simple-git-deploy deploy <git-branch-name>. But before first usage you must create a deploy.ini file with at least the settings below (look further for an example):

  • dirs.deploy: directory where your application will be deployed. The current deployment will be available at current under this directory. This will be a symlink to the actual deployment directory.

    So, for example, if you have a PHP application, you can point Nginx to the /app/deployments/current directory which will contain a working tree of your Git repository and will be updated whenever you deploy a new version, provided you add this to your deploy.ini:

    [dirs]
    deploy = /app/deployments
    

    Each deployment will also live in this directory with a name containing the date/time of the deployment, the Git commit hash and the name of the branch/tag that was deployed.

  • build.run: which command to run in the build phase. Typical usages are running your package manager, copying configuration files, compiling assets.

    This is run as a shell command line – so you can chain commands as in npm install && npm run build.

A complete configuration file would thus be:

[dirs]
deploy = /app/deployments

[build]
run = npm install && npm run build

It is assumed that the build will be run in the same host where the application is to be deployed. Also, the user running this script must have permission to write on the deployment directory.

Purging old deployments

You can purge old deployments with simple-git-deploy purge. There are two ways to specify what exactly is to be removed:

  • --keep-latest N: keep only the latest N deployments (other than the current one). With N=0, only the current deployment is kept, and with N=1 only one deployment other than the current is kept.
  • --older-than DATETIME: discard deployments with a timestamp strictly older than the given date/time. A wide range of both absolute and relative formats is accepted; see the dateparser documentation for full information. Common cases may be written as 10d, 1w (10 days and 1 week, respectively).

Development setup

If you want to set this project up for development, see CONTRIBUTING.md.

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

simple-git-deploy-0.4.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

simple_git_deploy-0.4.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file simple-git-deploy-0.4.0.tar.gz.

File metadata

  • Download URL: simple-git-deploy-0.4.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for simple-git-deploy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9bb137f95400f8a048f82db12aea8012ff0e94613043b1febeb6f3760ab30e7b
MD5 905ebf607792c2c5cfad7093cb4b4dc8
BLAKE2b-256 3d179294ad9f6364f90e1a2a58511c51dd683caf0ad33108f87d3b4afe402e6c

See more details on using hashes here.

File details

Details for the file simple_git_deploy-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: simple_git_deploy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for simple_git_deploy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3553476e4461e52e6c3ac3f70b91f62cc5ced3d6d330e0d33d9250b81e1e6d6c
MD5 ef4c272a042a43a0fa5084f8ea4cd66d
BLAKE2b-256 7d02db20cb61b2c2ee1eabee0bfdbf8fdf05a18164f6ea81a8a3dd3d08b05a0c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page