2017 © Pedro Peláez
 

symfony-bundle versioning-bundle

Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

image

shivas/versioning-bundle

Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

  • Monday, April 30, 2018
  • by shivas
  • Repository
  • 3 Watchers
  • 45 Stars
  • 116,674 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 22 Versions
  • 13 % Grown

The README.md

versioning-bundle

SensioLabsInsight Total Downloads, (*1)

Simple way to version your Symfony Flex application., (*2)

What it is:

  • Automatically keep track of your application version using Git tags or a Capistrano REVISION file
  • Adds a global Twig variable for easy access
  • Easy to extend with new version providers and formatters for different SCM's or needs
  • Uses Semantic Versioning 2.0.0 recommendations using https://github.com/nikolaposa/version library
  • Support for manual version management

Purpose:

To have an environment variable in your Symfony application with the current version of the application for various needs: - Display in frontend - Display in backend - Anything you can come up with, (*3)

Providers implemented:

  • VersionProvider (read the version from a VERSION file)
  • GitRepositoryProvider (git tag describe provider to automatically update the version by looking at git tags)
  • RevisionProvider (read the version from a REVISION file)
  • InitialVersionProvider (just returns the default initial version 0.1.0)

Installation

Symfony Flex automates the installation process, just require the bundle in your application!, (*4)

composer require shivas/versioning-bundle

The version is automatically available in your application., (*5)

# Twig template
{{ shivas_app_version }}

# Or get the version from the service
public function indexAction(VersionManagerInterface $manager)
{
    $version = $manager->getVersion();
}

Console commands

There are three available console commands. You only need to run the app:version:bump command when manually managing your version number., (*6)

# Display the application version status
bin/console app:version:status

# Display all available version providers
bin/console app:version:list-providers

# Manually bump the application version
bin/console app:version:bump

Version providers

Providers are used to get a version string for your application. All versions should follow the SemVer 2.0.0 notation, with the exception that letter "v" or "V" may be prefixed, e.g. v1.0.0. The recommended version provider is the GitRepositoryProvider which only works when you have at least one TAG in your repository. Be sure that all of your TAGS are valid version numbers., (*7)

Adding own provider

It's easy, write a class that implements the ProviderInterface:, (*8)

namespace App\Provider;

use Shivas\VersioningBundle\Provider\ProviderInterface;

class MyCustomProvider implements ProviderInterface
{

}

Add the provider to the container using your services file:, (*9)

App\Provider\MyCustomProvider:
    tags:
        - { name: shivas_versioning.provider, alias: my_provider, priority: 0 }
<service id="App\Provider\MyCustomProvider">
    <tag name="shivas_versioning.provider" alias="my_provider" priority="0" />
</service>

Please take a look at the priority attribute, it should be between 0 and 99 to keep the providers in the right order., (*10)

Ensure your provider is loaded correctly and supported:, (*11)

bin/console app:version:list-providers

Registered version providers
 ============= ========================================================= ========== ===========
  Alias         Class                                                     Priority   Supported
 ============= ========================================================= ========== ===========
  version       Shivas\VersioningBundle\Provider\VersionProvider          100        No
  my_provider   App\Provider\MyCustomProvider                             0          Yes
  git           Shivas\VersioningBundle\Provider\GitRepositoryProvider    -25        Yes
  revision      Shivas\VersioningBundle\Provider\RevisionProvider         -50        No
  init          Shivas\VersioningBundle\Provider\InitialVersionProvider   -75        Yes
 ============= ========================================================= ========== ===========

Version formatters

Version formatters are used to modify the version string to make it more readable. The default GitDescribeFormatter works in the following fashion:, (*12)

  • if the commit sha matches the last tag sha then the tag is converted to the version as is
  • if the commit sha differs from the last tag sha then the following happens:
    • the tag is parsed as the version
    • the prerelease part is added with following data: "dev.abcdefa"
    • where the prerelease part "dev" means that the version is not tagged and is "dev" stable, and the last part is the commit sha

If you want to disable the default formatter, use the NullFormatter:, (*13)

# app/config/services.yaml
Shivas\VersioningBundle\Formatter\NullFormatter: ~
Shivas\VersioningBundle\Formatter\FormatterInterface: '@Shivas\VersioningBundle\Formatter\NullFormatter'

Creating your own version formatter

To customize the version format, write a class that implements the FormatterInterface:, (*14)

namespace App\Formatter;

use Shivas\VersioningBundle\Formatter\FormatterInterface;

class MyCustomFormatter implements FormatterInterface
{

}

Then alias the FormatterInterface with your own:, (*15)

# app/config/services.yaml
Shivas\VersioningBundle\Formatter\FormatterInterface: '@App\Formatter\MyCustomFormatter'

Capistrano v3 task for creating a REVISION file

Add following to your recipe, (*16)

namespace :deploy do
    task :add_revision_file do
        on roles(:app) do
            within repo_path do
                execute(:git, :'describe', :"--tags --long",
                :"#{fetch(:branch)}", ">#{release_path}/REVISION")
            end
        end
    end
end

# We get git describe --tags just after deploy:updating
after 'deploy:updating', 'deploy:add_revision_file'

Good luck versioning your project., (*17)

Contributions for different SCM's and etc are welcome, just submit a pull request., (*18)

The Versions

30/04 2018

dev-master

9999999-dev https://github.com/shivas/versioning-bundle

Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

30/04 2018

3.1.3

3.1.3.0 https://github.com/shivas/versioning-bundle

Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

06/03 2018

3.1.2

3.1.2.0 https://github.com/shivas/versioning-bundle

Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

18/02 2018

2.0.0.x-dev

2.0.0.9999999-dev https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

18/02 2018

2.0.1

2.0.1.0 https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

17/02 2018

3.1.1

3.1.1.0 https://github.com/shivas/versioning-bundle

Symfony3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

08/02 2018

3.0.1

3.0.1.0 https://github.com/shivas/versioning-bundle

Symfony2|3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

25/01 2018

3.0.0.x-dev

3.0.0.9999999-dev https://github.com/shivas/versioning-bundle

Symfony2|3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

25/01 2018

3.0.0

3.0.0.0 https://github.com/shivas/versioning-bundle

Symfony2|3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

25/01 2018

dev-3.0.0-alpha

dev-3.0.0-alpha https://github.com/shivas/versioning-bundle

Symfony2|3|4 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

19/11 2017

2.0.0

2.0.0.0 https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

07/02 2017

dev-2.0.0-alpha

dev-2.0.0-alpha https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

06/02 2017

1.4.2

1.4.2.0 https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

30/01 2017

1.4.1

1.4.1.0 https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

26/01 2017

1.4.0

1.4.0.0 https://github.com/shivas/versioning-bundle

Symfony2|3 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

02/12 2015

1.3.0

1.3.0.0 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

28/10 2015

1.2.0

1.2.0.0 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

The Development Requires

by Audrius Karabanovas

version semantic versioning semver

07/02 2015

1.1.0

1.1.0.0 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

by Audrius Karabanovas

version semantic versioning

18/12 2013

1.0.1

1.0.1.0 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

by Audrius Karabanovas

version semantic versioning

17/12 2013

1.0.0

1.0.0.0 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

by Audrius Karabanovas

version semantic versioning

23/07 2013

1.0.0-RC2

1.0.0.0-RC2 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

by Audrius Karabanovas

version semantic versioning

23/07 2013

1.0.0-RC1

1.0.0.0-RC1 https://github.com/shivas/versioning-bundle

Symfony2 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations

  Sources   Download

MIT

The Requires

 

by Audrius Karabanovas

version semantic versioning