Giter Site home page Giter Site logo

git integration about semver HOT 2 CLOSED

defji avatar defji commented on May 18, 2024 1
git integration

from semver.

Comments (2)

PHLAK avatar PHLAK commented on May 18, 2024

Can you elaborate on how you would like this to work?

from semver.

jordanbrauer avatar jordanbrauer commented on May 18, 2024

@defji The way I've integrated programatic semver handling to Git repository management, is like so – using command line automation tools (such as Robo):

/**
 * Tag the current state of the repository.
 *
 * @param string $version The name of the tag.
 * @param boolean $commitTag (optional) Commit the tag or not.
 * @return void
 */
public function tagRelease(string $version, bool $commitTag = true)
{
    if ($commitTag) {
        $this->taskGitStack()
            ->stopOnFail()
            ->tag('v'.ltrim($version, 'v'), 'Tag release for v'.$version)
            ->run();
    }
}

This is within a Robofile.php (using the Robo task runner) libraries' built-in Git support. It would then be used on the command line, like so:

php robo.phar tag:release v1.2.3

Even further – you can also automate entire releases using the tagRelease method (modified for your needs, of course) within another method.

/**
 * Release the next stable version of the package.
 *
 * @param string $version A valid semver version scheme string to set as the next version and tag.
 * @param bool $commit Should the changes be commited and tagged?
 * @return void
 */
public function releaseStable(string $version, bool $commit = true): void
{
    $this->checkoutMaster($commit);
    $this->tagRelease($version, $commit);
    $this->pushAll($version, $commit);
    $this->upgradeDocumentation($version, $commit);
    $this->upgradeChangelog($version, $commit);
    $this->removeTag($version, $commit);
    $this->tagRelease($version, $commit);
    $this->pushAll($version, $commit);
    echo PHP_EOL;
    $this->say("Successfully bumped version to <fg=blue>v</><fg=cyan>{$version}</>");
}

Used on the command line, like so:

php robo.phar release:stable v1.2.3

It's worked pretty good for my own needs. YMMV though. 🙂

from semver.

Related Issues (12)

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.