Coder Social home page Coder Social logo

php-build-tools's Introduction

Build Tools

Build Status Scrutinizer Code Quality Code Coverage

Build tools that should assist in CI/CD environments.

Requirements

  • PHP 5.5.9 or higher, 7.x
  • Git client

1. Semantic Version Increment

More information about semantic versioning can be found here: http://semver.org/

1.1 Introduction

This is a simple PHP command that can be run to increment the PATCH version part of a version string MAJOR.MINOR.PATCH by a number of units:

  • Reads current version from the ini file. Eg: VERSION=0.1.1 (file name is VERSION)
  • Increments the PATCH part of the version and writes the new version to the ini file. Eg: VERSION=0.1.2
  • Commits the changes to the repository
  • Creates a new tag for the new version. Eg: 0.1.2

Because it uses an ini file, it is therefore easy to integrate the script withing a Jenkins building job and expose the incremented version as an environment variable.

1.2 Run the command

php command.php version:increment [repository-path] --git-path=git

Arguments

  • repository-path - relative or absolute path to git repository folder. For current folder use .

Options

  • --version-filename (Default: VERSION) - The name of the ini file where the version is stored. Have a look at this version file.
  • --git-path (Default: /usr/bin/git) - Absolute path to git client executable. If you have git added to the environment path you can use only the name of the executable.
  • --commit-message (Default: "Bumped version to %s") - Customize commit message where the %s is the token replaced with the new incremented version.
  • --author-name - Change the default git author name for the committed message.
  • --author-email - Change the default git author email for the commited message.
  • --dry-run - Run the command without doing any actual changes to the version file

The file will read current git tags and if current hash has no tag associated with it, it will increment patch part of the version file with 1.

If there are no tags defined, the script will assume that this is the first version and it will not increment the patch part version.

E.g.

VERSION file has the following version: 0.1.0 git tag does not return anything. This is the first version, no action is taken.

VERSION file has the following version: 0.1.0 git tag returns tag 0.1.0 associated with a previous hash. The script will increment the patch part of the version file with 1.

Git actions after increment

It is mandatory to create a new tag for the current written version inside VERSION file and push changes to git.

You will have to use git publisher.

Run

Run without actually incrementing the file:

php command.php version:increment . --dry-run=true
php command.php version:increment [path_to_git_repository] --version-filename=VERSION

TODO:

Check if incremented version has a tag associated with it.

Tremend Software Consulting

Tremend Software Consulting

php-build-tools's People

Watchers

 avatar  avatar

Forkers

guoyu07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.