diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d33ba9a --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +node_modules +.DS_Store +Desktop.ini +._* +Thumbs.db +*.tmp +*.bak +*.log +*.lock +logs +package-lock.json diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c429923 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +# https://github.com/koalaman/shellcheck/wiki/TravisCI +sudo: required + +language: bash + +services: + - docker + +before_install: + - docker pull koalaman/shellcheck + +script: + - docker run -v $(pwd):/scripts koalaman/shellcheck index.sh + +matrix: + fast_finish: true \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1b56d9d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Federico Brigante (bfred.it) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c251703 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# daily-version [![Build Status](https://travis-ci.org/bfred-it/daily-version.svg?branch=master)](https://travis-ci.org/bfred-it/daily-version) + +> Get the current date formatted as a version. Automatically add the time if you already released a version today. + +This command line tool can be used to version your nightly builds while still allowing hot patches to have their own version number. + + +## Install + +``` +$ npm install --save daily-version +``` + + +## Usage + +```sh +$ daily-version +17.8.29 + +$ daily-version +17.8.29.1451 +``` + +For example, it can be used to set the version of a Web Extension in a Travis cronjob: + +```yml +script: + - dot-json manifest.json version $(daily-version) + - webstore upload --auto-publish +``` + + +## License + +MIT © [Federico Brigante](http://twitter.com/bfred_it) + diff --git a/index.sh b/index.sh new file mode 100755 index 0000000..aee4eb1 --- /dev/null +++ b/index.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +mkdir -p ~/.version-store/ + +CURR=$(date -u +%y.%-m.%-d) +PREV=$(cat ~/.version-store/v 2>/dev/null || true) + +if [[ $PREV =~ ^$CURR ]]; then + CURR=$(date -u +%y.%-m.%-d.%-H%M) +fi + +echo "$CURR" > ~/.version-store/v +echo "$CURR" diff --git a/package.json b/package.json new file mode 100644 index 0000000..9eb379b --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "daily-version", + "version": "0.0.0", + "description": "Get the current date formatted as a version. Automatically add the time if you already released a version today.", + "bin": "index.sh", + "license": "MIT", + "repository": "bfred-it/daily-version", + "author": "Federico Brigante (bfred.it)", + "keywords": [], + "files": [ + "index.sh" + ], + "scripts": { + "test": "shellcheck index.sh" + } +}