Semantic Versioning 2.0.0 | Semantic Versioning

Web Name: Semantic Versioning 2.0.0 | Semantic Versioning

WebSite: http://semver.org

ID:119005

Keywords:

Semantic,Versioning,

Description:

MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards compatiblemanner, and PATCH version when you make backwards compatible bug fixes.Additional labels for pre-release and build metadata are available as extensionsto the MAJOR.MINOR.PATCH format.IntroductionIn the world of software management there exists a dreaded place called“dependency hell.” The bigger your system grows and the more packages youintegrate into your software, the more likely you are to find yourself, oneday, in this pit of despair.In systems with many dependencies, releasing new package versions can quicklybecome a nightmare. If the dependency specifications are too tight, you are indanger of version lock (the inability to upgrade a package without having torelease new versions of every dependent package). If dependencies arespecified too loosely, you will inevitably be bitten by version promiscuity(assuming compatibility with more future versions than is reasonable).Dependency hell is where you are when version lock and/or version promiscuityprevent you from easily and safely moving your project forward.As a solution to this problem, I propose a simple set of rules andrequirements that dictate how version numbers are assigned and incremented.These rules are based on but not necessarily limited to pre-existingwidespread common practices in use in both closed and open-source software.For this system to work, you first need to declare a public API. This mayconsist of documentation or be enforced by the code itself. Regardless, it isimportant that this API be clear and precise. Once you identify your publicAPI, you communicate changes to it with specific increments to your versionnumber. Consider a version format of X.Y.Z (Major.Minor.Patch). Bug fixes notaffecting the API increment the patch version, backwards compatible APIadditions/changes increment the minor version, and backwards incompatible APIchanges increment the major version.I call this system “Semantic Versioning.” Under this scheme, version numbersand the way they change convey meaning about the underlying code and what hasbeen modified from one version to the next.Semantic Versioning Specification (SemVer)The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”,“SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to beinterpreted as described in RFC 2119. Software using Semantic Versioning MUST declare a public API. This APIcould be declared in the code itself or exist strictly in documentation.However it is done, it SHOULD be precise and comprehensive. A normal version number MUST take the form X.Y.Z where X, Y, and Z arenon-negative integers, and MUST NOT contain leading zeroes. X is themajor version, Y is the minor version, and Z is the patch version.Each element MUST increase numerically. For instance: 1.9.0 - 1.10.0 - 1.11.0. Once a versioned package has been released, the contents of that versionMUST NOT be modified. Any modifications MUST be released as a new version. Major version zero (0.y.z) is for initial development. Anything MAY changeat any time. The public API SHOULD NOT be considered stable. Version 1.0.0 defines the public API. The way in which the version numberis incremented after this release is dependent on this public API and how itchanges. Patch version Z (x.y.Z | x 0) MUST be incremented if only backwardscompatible bug fixes are introduced. A bug fix is defined as an internalchange that fixes incorrect behavior. Minor version Y (x.Y.z | x 0) MUST be incremented if new, backwardscompatible functionality is introduced to the public API. It MUST beincremented if any public API functionality is marked as deprecated. It MAY beincremented if substantial new functionality or improvements are introducedwithin the private code. It MAY include patch level changes. Patch versionMUST be reset to 0 when minor version is incremented. Major version X (X.y.z | X 0) MUST be incremented if any backwardsincompatible changes are introduced to the public API. It MAY also include minorand patch level changes. Patch and minor version MUST be reset to 0 when majorversion is incremented. A pre-release version MAY be denoted by appending a hyphen and aseries of dot separated identifiers immediately following the patchversion. Identifiers MUST comprise only ASCII alphanumerics and hyphens[0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers MUSTNOT include leading zeroes. Pre-release versions have a lowerprecedence than the associated normal version. A pre-release versionindicates that the version is unstable and might not satisfy theintended compatibility requirements as denoted by its associatednormal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7,1.0.0-x.7.z.92, 1.0.0-x-y-z.–. Build metadata MAY be denoted by appending a plus sign and a series of dotseparated identifiers immediately following the patch or pre-release version.Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].Identifiers MUST NOT be empty. Build metadata MUST be ignored when determiningversion precedence. Thus two versions that differ only in the build metadata,have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700,1.0.0-beta+exp.sha.5114f85, 1.0.0+21AF26D3—-117B344092BD. Precedence MUST be calculated by separating the version into major,minor, patch and pre-release identifiers in that order (Build metadatadoes not figure into precedence). Precedence is determined by the first difference when comparing each ofthese identifiers from left to right as follows: Major, minor, and patchversions are always compared numerically. Example: 1.0.0 2.0.0 2.1.0 2.1.1. When major, minor, and patch are equal, a pre-release version has lowerprecedence than a normal version: Example: 1.0.0-alpha 1.0.0. Precedence for two pre-release versions with the same major, minor, andpatch version MUST be determined by comparing each dot separated identifierfrom left to right until a difference is found as follows: A larger set of pre-release fields has a higher precedence than asmaller set, if all of the preceding identifiers are equal. Example: 1.0.0-alpha 1.0.0-alpha.1 1.0.0-alpha.beta 1.0.0-beta 1.0.0-beta.2 1.0.0-beta.11 1.0.0-rc.1 1.0.0.Backus–Naur Form Grammar for Valid SemVer Versions valid semver ::= version core | version core "-" pre-release | version core "+" build | version core "-" pre-release "+" build version core ::= major "." minor "." patch major ::= numeric identifier minor ::= numeric identifier patch ::= numeric identifier pre-release ::= dot-separated pre-release identifiers dot-separated pre-release identifiers ::= pre-release identifier | pre-release identifier "." dot-separated pre-release identifiers build ::= dot-separated build identifiers dot-separated build identifiers ::= build identifier | build identifier "." dot-separated build identifiers pre-release identifier ::= alphanumeric identifier | numeric identifier build identifier ::= alphanumeric identifier | digits alphanumeric identifier ::= non-digit | non-digit identifier characters | identifier characters non-digit | identifier characters non-digit identifier characters numeric identifier ::= "0" | positive digit | positive digit digits identifier characters ::= identifier character | identifier character identifier characters identifier character ::= digit | non-digit non-digit ::= letter | "-" digits ::= digit | digit digits digit ::= "0" | positive digit positive digit ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" letter ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"Why Use Semantic Versioning?This is not a new or revolutionary idea. In fact, you probably do somethingclose to this already. The problem is that “close” isn’t good enough. Withoutcompliance to some sort of formal specification, version numbers areessentially useless for dependency management. By giving a name and cleardefinition to the above ideas, it becomes easy to communicate your intentionsto the users of your software. Once these intentions are clear, flexible (butnot too flexible) dependency specifications can finally be made.A simple example will demonstrate how Semantic Versioning can make dependencyhell a thing of the past. Consider a library called “Firetruck.” It requires aSemantically Versioned package named “Ladder.” At the time that Firetruck iscreated, Ladder is at version 3.1.0. Since Firetruck uses some functionalitythat was first introduced in 3.1.0, you can safely specify the Ladderdependency as greater than or equal to 3.1.0 but less than 4.0.0. Now, whenLadder version 3.1.1 and 3.2.0 become available, you can release them to yourpackage management system and know that they will be compatible with existingdependent software.As a responsible developer you will, of course, want to verify that anypackage upgrades function as advertised. The real world is a messy place;there’s nothing we can do about that but be vigilant. What you can do is letSemantic Versioning provide you with a sane way to release and upgradepackages without having to roll new versions of dependent packages, saving youtime and hassle.If all of this sounds desirable, all you need to do to start using SemanticVersioning is to declare that you are doing so and then follow the rules. Linkto this website from your README so others know the rules and can benefit fromthem.How should I deal with revisions in the 0.y.z initial development phase?The simplest thing to do is start your initial development release at 0.1.0and then increment the minor version for each subsequent release.How do I know when to release 1.0.0?If your software is being used in production, it should probably already be1.0.0. If you have a stable API on which users have come to depend, you shouldbe 1.0.0. If you’re worrying a lot about backwards compatibility, you shouldprobably already be 1.0.0.Doesn’t this discourage rapid development and fast iteration?Major version zero is all about rapid development. If you’re changing the APIevery day you should either still be in version 0.y.z or on a separatedevelopment branch working on the next major version.If even the tiniest backwards incompatible changes to the public API require a major version bump, won’t I end up at version 42.0.0 very rapidly?This is a question of responsible development and foresight. Incompatiblechanges should not be introduced lightly to software that has a lot ofdependent code. The cost that must be incurred to upgrade can be significant.Having to bump major versions to release incompatible changes means you’llthink through the impact of your changes, and evaluate the cost/benefit ratioinvolved.Documenting the entire public API is too much work!It is your responsibility as a professional developer to properly documentsoftware that is intended for use by others. Managing software complexity is ahugely important part of keeping a project efficient, and that’s hard to do ifnobody knows how to use your software, or what methods are safe to call. Inthe long run, Semantic Versioning, and the insistence on a well defined publicAPI can keep everyone and everything running smoothly.What do I do if I accidentally release a backwards incompatible change as a minor version?As soon as you realize that you’ve broken the Semantic Versioning spec, fixthe problem and release a new minor version that corrects the problem andrestores backwards compatibility. Even under this circumstance, it isunacceptable to modify versioned releases. If it’s appropriate,document the offending version and inform your users of the problem so thatthey are aware of the offending version.What should I do if I update my own dependencies without changing the public API?That would be considered compatible since it does not affect the public API.Software that explicitly depends on the same dependencies as your packageshould have their own dependency specifications and the author will notice anyconflicts. Determining whether the change is a patch level or minor levelmodification depends on whether you updated your dependencies in order to fixa bug or introduce new functionality. I would usually expect additional codefor the latter instance, in which case it’s obviously a minor level increment.What if I inadvertently alter the public API in a way that is not compliant with the version number change (i.e. the code incorrectly introduces a major breaking change in a patch release)?Use your best judgment. If you have a huge audience that will be drasticallyimpacted by changing the behavior back to what the public API intended, thenit may be best to perform a major version release, even though the fix couldstrictly be considered a patch release. Remember, Semantic Versioning is allabout conveying meaning by how the version number changes. If these changesare important to your users, use the version number to inform them.How should I handle deprecating functionality?Deprecating existing functionality is a normal part of software development andis often required to make forward progress. When you deprecate part of yourpublic API, you should do two things: (1) update your documentation to letusers know about the change, (2) issue a new minor release with the deprecationin place. Before you completely remove the functionality in a new major releasethere should be at least one minor release that contains the deprecation sothat users can smoothly transition to the new API.Does SemVer have a size limit on the version string?No, but use good judgment. A 255 character version string is probably overkill,for example. Also, specific systems may impose their own limits on the size ofthe string.Is “v1.2.3” a semantic version?No, “v1.2.3” is not a semantic version. However, prefixing a semantic versionwith a “v” is a common way (in English) to indicate it is a version number.Abbreviating “version” as “v” is often seen with version control. Example:git tag v1.2.3 -m "Release version 1.2.3", in which case “v1.2.3” is a tagname and the semantic version is “1.2.3”.Is there a suggested regular expression (RegEx) to check a SemVer string?There are two. One with named groups for those systems that support them(PCRE [Perl Compatible Regular Expressions, i.e. Perl, PHP and R], Pythonand Go).See: https://regex101.com/r/Ly7O1x/3/^(?P major 0|[1-9]\d*)\.(?P minor 0|[1-9]\d*)\.(?P patch 0|[1-9]\d*)(?:-(?P prerelease (?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P buildmetadata [0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$And one with numbered capture groups instead (so cg1 = major, cg2 = minor,cg3 = patch, cg4 = prerelease and cg5 = buildmetadata) that is compatiblewith ECMA Script (JavaScript), PCRE (Perl Compatible Regular Expressions,i.e. Perl, PHP and R), Python and Go.See: https://regex101.com/r/vkijKf/1/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$AboutThe Semantic Versioning specification was originally authored by TomPreston-Werner, inventor of Gravatar andcofounder of GitHub.If you’d like to leave feedback, please open an issue onGitHub.LicenseCreative Commons ― CC BY 3.0

TAGS:Semantic Versioning 

<<< Thank you for your visit >>>

Semantic Versioning spec and website

Websites to related :
Personal Computer Fixes -

  This year, Microsoft has officially discontinued all support for Windows 7. Now this favorite OS is as obsolete as Windows XP, which means that you sh

Art History Today

  Just several years after Mackintosh’s School of Art caught fire, and was repaired, it catches fire again. As this photo from the Guardian shows, the

Doula Faith | Encouragement in t

  “And the Lordsaid,“Listen to what the unjust judge says.And will not God bring about justice for his chosen ones, who cry outto him day and night? W

Eu Acredito em Cosméticos |Late

  Se tem uma coisa que eu viciei nesta jornada cabelística, é em lavar os cabelos com condicionador (técnica no-poo, co-wash - veja explicação no

Mankato Clinic

  Feature > See All You can lower your risk for diabetes Many of us are at a higher risk for type 2 diabetes. Approximately 88 million American adults,

Allergy & Asthma Clinic of San M

  The San Mateo Clinic will be open for ALLERGY SHOTS on Wednesday, November 25, 2020 from 9:00am-3:30pmVideo Visits with an Allergy and Asthma Clinic H

PR Agency Sydney | Boutique Publ

  The Atticism is a boutique public relations and business development agency founded in Sydney in 2012.  We specialise in public relations, business d

Allergy Asthma Medical Group of

  Get The Latest News! Get the latest news about what's going on at AAMG. Read More Download Our Forms If the office needs a form filled out, get them h

Welcome! | Allergy & Asthma Cent

  At Allergy and Asthma Center our unique expertise provides a comprehensive look at the causes of asthma, allergies and recurrent sinus, ear and chest

Psychological Assessment Resou

  This site requires JavaScript to be enabled on your browser in order to function properly. Please enable JavaScript on your browser. Visit our COVID-1

ads

Hot Websites