Code Monkey home page Code Monkey logo

semanticversioning's Introduction

SemanticVersioning [x.x.x]

This package provides the Swift protocol compatible with Semantic Versioning (2.0.0).

Test MIT License Latest Version

Features

  • By conforming to the SemanticVersioning protocol, it can be represented as a type that behaves as a version of software compliant with Semantic Versioning (2.0.0).

    import SemanticVersioning
    
    // conforms to SemanticVersioning
    struct MyAppVersion: SemanticVersioning {
      let major: Int
      let minor: Int
      let patch: Int
      let preRelease: PreRelease?
      let buildMetaData: String?
    }
  • Can be initialized from String literals.

    let appVersion: MyAppVersion = "1.1.1"
    // String literals can also contain pre-release and build metadata.
    // let appVersion: MyAppVersion = "1.1.1-alpha"
    // let appVersion: MyAppVersion = "1.1.1-alpha+build.1"
  • Comparable and Equatable.

    if appVersion > "1.0.0" {
      // Some operation when appVersion is greater than 1.0.0
    } else if appVersion == "0.1.0" {
      // Some operation when appVersion is 0.1.0 
    }
  • Increment version number.

    print(appVersion)
    // -> 1.1.1
    print(appVersion.increment(.major))
    // -> 2.0.0
    print(appVersion.increment(.minor))
    // -> 1.2.0
    print(appVersion.increment(.patch))
    // -> 1.1.2
  • Validate version format with macro.

    import SemanticVersioningMacro
    
    let validVersionString = #semanticVersioning("1.0.0") // Valid format!
    let invalidVersionString = #semanticVersioning("1.0.a") // Invalid format! Compile error!

Requirements

  • Swift 5.9 or later
  • macOS 10.15+ or iOS 12.0+ or watchOS 4.0+ or tvOS 1.0+

Supported Platforms

  • Apple Platforms
  • Linux

Usage

Package.swift

  1. Add SemanticVersioning to your Package.swift dependencies:

    .package(url: "https://github.com/taji-taji/SemanticVersioning.git", from: "1.0.0")
  2. Add SemanticVersioning to your dependencies of SemanticVersioning target:

    .product(name: "SemanticVersioning", package: "SemanticVersioning"),
    // If you want to use macro, add `SemanticVersioningMacro`. 
    .product(name: "SemanticVersioningMacro", package: "SemanticVersioning"),

semanticversioning's People

Contributors

taji-taji avatar

Watchers

 avatar  avatar  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.