Giter Club home page Giter Club logo

semverharvester's Introduction

SemVerHarvester

SemVerHarvester is a MSBuild task library that harvests version numbers from tags in source control repositories.

SemVerHarvester expects version tags in the format "v1.1.1" It parces the numeric triple (1.1.1) into major version, minor version, and patch version. The number of commits between the last version tag and HEAD for the current branch is returned in revision version, and if untracked changes are found, a modified property is set to " (Modified)".

Instructions

Add the package from NuGet by running the following command in the Package Manager Console:

Install-Package SemVerHarvester

Next, add the build target to your project file:

<Import Project="$(MSBuildProjectDirectory)\..\packages\SemVerHarvester.0.3.0\msbuild\SemVerHarvester.Targets" />

Then, add the following to your BeforeBuild target in your project file:

<Target Name="BeforeBuild">
    <SemVerGitHarvester GitPath="C:\Program Files\Git\bin\git.exe">
        <Output TaskParameter="MajorVersion" PropertyName="MajorVersion" />
        <Output TaskParameter="MinorVersion" PropertyName="MinorVersion" />
        <Output TaskParameter="PatchVersion" PropertyName="PatchVersion" />
        <Output TaskParameter="RevisionVersion" PropertyName="RevisionVersion" />
        <Output TaskParameter="ModifiedString" PropertyName="ModifiedString" />
    </SemVerGitHarvester>
</Target>

You will then have $(MajorVersion), $(MinorVersion), etc., available to use in your project file. If you're using MSBuildCommunityTasks, you can use the AssemblyFile task to generate assembly information:

<AssemblyInfo OutputFile="Properties\VersionAssemblyInfo.cs"
              CodeLanguage="CS"
              AssemblyVersion="$(MajorVersion).$(MinorVersion).$(PatchVersion).$(RevisionVersion)"
              AssemblyFileVersion="$(MajorVersion).$(MinorVersion).$(PatchVersion).$(RevisionVersion)"
              AssemblyInformationalVersion="$(MajorVersion).$(MinorVersion).$(PatchVersion).$(RevisionVersion)$(ModifiedString)" />

The output of git-describe will be transformed as follows:

git-describe                     Major  Minor  Patch  Revision  ModifiedString    Explanation
--------------------------       ------ ------ ------ --------- ---------------   -----------------------------
v1.2.3-0-g1ab2cd3           ==>  "1"    "2"    "3"    "0"       ""                tag="v1.2.3" found, no commits after tag
v1.2.3-4-g1ab2cd3           ==>  "1"    "2"    "3"    "4"       ""                tag="v1.2.3" found, 4 commits after tag
v1.2.3-0-g1ab2cd3-modified  ==>  "1"    "2"    "3"    "0"       " (Modified)"     tag="v1.2.3" found, no commits after tag, untracked changes found
v1.2.3-4-g1ab2cd3-modified  ==>  "1"    "2"    "3"    "4"       " (Modified)"     tag="v1.2.3" found, 4 commits after tag, untracked changes found
1ab2cd3                     ==>  "0"    "0"    "0"    "0"       ""                no semVer tag found
1ab2cd3-modified            ==>  "0"    "0"    "0"    "0"       " (Modified)"     no semVer tag found, untracked changes found

Source Code

SemVerHarvester is on GitHub:

http://github.com/jennings/SemVerHarvester

License

Copyright 2011 Stephen Jennings

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

semverharvester's People

Contributors

davistan avatar grynn avatar jennings avatar marfarma avatar ziaw avatar

Stargazers

 avatar

Watchers

 avatar

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.