Giter Club home page Giter Club logo

swift-semver's Introduction

Swift Semantic Versioning

A small library that implements SemVer 2.0.0. This is designed to be simple to use and to easily fit into any Swift codebase.

Examples

Let's say you have a release candidate of version 2.0 of your app. The following are all equivalent:

_ = SemVer(major: 2, minor: 0, preRelease: ["RC", 1])
_ = SemVer(2,0,0, preRelease: ["RC",1])
_ = SemVer("2.0-RC.1")
_ = SemVer("2.0.0-RC.1")

These can also be compared using Swift comparison operators. For instance, all these are true:

SemVer("2.0") == SemVer("2.0.0")
SemVer("1.2.0") < SemVer("2.0.0")
SemVer("1.2.0") <= SemVer("2.0.0")
SemVer("12.0") > SemVer("2.9.9")

Since this conforms to Semantic Version 2.0.0, attempting to use an invalid semantic version as a string will result in a nil object:

nil == SemVer("Obviously Bad")
nil == SemVer("1")
nil == SemVer("-2.0")
nil == SemVer("2.0-ฮฒ")
nil == SemVer("2.0-beta_1")
nil == SemVer("1.-2")
nil == SemVer("1.2.-3")
nil == SemVer("1.2.3.4")

License

This is licensed under BH-1-PS Opus 2.

swift-semver's People

Contributors

kyleggiero avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swift-semver's Issues

Enforce increment-only semantic versions

One feature of this library is that it helps you mutate the semantic version; this is why it's never been a static value.

To increase this assistance, instances should enforce that changing a semantic version's MAJOR/MINOR/PATCH values only results in increments, as per SemVer rule 2:

Each element MUST increase numerically

Finish documenting

Documentation is almost complete, but there are lines like this:

    /// The PATCH version; increment this when you

And some undocumented fields like:

    public var preRelease: PreRelease?
    public var build: Build?

Drop Swift 4 support

It's over a year out, and Swift 5 is an easy migration path. If you're reading this and you're sad that this package doesn't support Swift 4, feel free to use an older release; it's been good since day 1 ๐Ÿ™‚

Update license

It's time to move from BH-1-PS Opus 2 to BH-1-PS Opus 3

Set up GitHub action

This will provide a nicely convenience CI way to test this with every PR.

Pairs nicely with #11

10.0 < 11.0 && 10.0 > 11.0

This should fail, but it does not:

let v10_0 = SemVer(10,0)
let v11_0 = SemVer(11,0)
assert(v10_0 < v11_0
    && v10_0 > v11_0)

This seems to be because isAscending(_:_:isLessThanNil:) erroneously returns true if both arguments are nil

Likely will be resolved with #5

Conform to Codable

It makes a lot of sense to be able to en- and de-code a SemVer, since the spec is just a string, and string parsing is already built

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.