Coder Social home page Coder Social logo

semver_bash's Introduction

semver_bash is a bash parser for semantic versioning

Semantic Versioning is a set of guidelines that help keep version and version management sane. This is a bash based parser to help manage a project's versions. Use it from a Makefile or any scripts you use in your project.

Usage

semver_bash can be used from the command line as:

$ ./semver.sh "3.2.1" "3.2.1-alpha"  
3.2.1 -> M: 3 m:2 p:1 s:  
3.2.1-alpha -> M: 3 m:2 p:1 s:-alpha  
3.2.1 == 3.2.1-alpha -> 1.  
3.2.1 < 3.2.1-alpha -> 1.  
3.2.1 > 3.2.1-alpha -> 0.

Alternatively, you can source it from within a script:

. ./semver.sh  

local MAJOR=0  
local MINOR=0  
local PATCH=0  
local SPECIAL=""

semverParseInto "1.2.3" MAJOR MINOR PATCH SPECIAL  
semverParseInto "3.2.1" MAJOR MINOR PATCH SPECIAL  

semver_bash's People

Contributors

damonoehlman avatar raybejjani avatar sublimino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

semver_bash's Issues

Logic Reversed?

It seems like the logic is reversed for the functions. As boolean operators i would expect EQ to return 1 if equals LT to return 1 if < and GT to return 1 if GT.

semverCheck

Could you add a function checking a semver string?

Sorting

This is my bubble sort funtion

declare -a VERSION=( ... )
BUBBLE="1"
while [ "$BUBBLE" == 1 ]; do
    BUBBLE="0"
    for I in $(seq 0 "$((${#VERSIONS[@]} - 1))"); do
        # Skip first element
        [ "$I" == 0 ] && continue

        PREVIOUS="$((I - 1))"
        if semverGT "${VERSIONS[$PREVIOUS]}" "${VERSIONS[$I]}"; then
            BUBBLE="1"
            BUFFER="${VERSIONS[$I]}"
            VERSIONS[$I]="${VERSIONS[$PREVIOUS]}"
            VERSIONS[$PREVIOUS]="$BUFFER"
        fi
    done
done

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.