From daa074f1cffabf9012e8b619000203990ac7152b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Vin=C3=ADcius=20Rubido?= Date: Fri, 10 May 2019 23:15:27 +0200 Subject: [PATCH] Fix travis (#30) * Update .travis.yml * Update .travis.yml * Update .travis.yml * Add version check to travis * Add NPM Package version check * Fix .travis.yml indentation * Increase commander version and fix echo in travis * Increase package version * Add if conditions for the deployment stages --- .travis.yml | 72 +++++++++++++++++++++++++++++++++++----------------- package.json | 2 +- src/index.ts | 2 +- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd211b9..e54a56f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,30 +3,56 @@ language: node_js node_js: - "node" - "lts/*" - -env: - global: - - REPO_VERSION="$(npx -c 'echo "$npm_package_version"')" - -before_install: - - echo "REPO_VERSION=$REPO_VERSION" - + before_script: - - npm run lint - -before_deploy: + - REPO_VERSION="$(npx -c 'echo "$npm_package_version"')" + - echo "REPO_VERSION=$REPO_VERSION" + - npm run build + - TPLANT_VERSION="$(node dist/index.js -V)" + - echo "TPLANT_VERSION=$TPLANT_VERSION" + - NPM_PACKAGE_VERSION="$(npx tplant -V)" + - echo "NPM_PACKAGE_VERSION=$NPM_PACKAGE_VERSION" + - echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" + - echo "TRAVIS_BRANCH=$TRAVIS_BRANCH" + - | + if [ "$REPO_VERSION" != "$TPLANT_VERSION" ]; then + echo -e '\033[0;31mPackage version and commander version must be the same.'; + travis_terminate 1; + fi - | - if [ "$TRAVIS_BRANCH" == "master" ]; then - git tag -a -f "$REPO_VERSION" - echo "New Tag $(git describe --tags)"; + if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ] && [ "$REPO_VERSION" == "$NPM_PACKAGE_VERSION" ]; then + echo -e '\033[0;31mPackage version must be higher than the current one.'; + travis_terminate 1; fi + - npm run lint + +jobs: + include: + - stage: "Github Deployment" + if: branch = master AND type = push + node_js: "lts/*" + install: skip + before_script: skip + script: skip + before_deploy: + - REPO_VERSION="$(npx -c 'echo "$npm_package_version"')" + - echo "REPO_VERSION=$REPO_VERSION" + - git tag -f "$REPO_VERSION" + - echo "New Tag $(git describe --tags)"; + + deploy: + provider: releases + api_key: $GITHUB_TOKEN -deploy: - - provider: releases - api_key: $GITHUB_TOKEN - on: - branch: master - - provider: npm - api_key: $NPM_API_KEY - on: - tags: true + - stage: "npm Deployment" + if: tag IS present + node_js: "lts/*" + before_script: skip + script: skip + deploy: + provider: npm + email: "brian.folts@gmail.com" + api_key: $NPM_API_KEY + skip_cleanup: true + on: + tags: true \ No newline at end of file diff --git a/package.json b/package.json index c6e8714..6edba12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tplant", - "version": "2.1.3", + "version": "2.1.4", "description": "Typescript to PlantUML", "keywords": [ "Class Diagram", diff --git a/src/index.ts b/src/index.ts index 0201ff9..0784def 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ import { convertToPlant } from './convertToPlant'; import { generateDocumentation } from './generateDocumentation'; commander - .version('2.1.3') + .version('2.1.4') .usage('[options]') .option('-i, --input ', 'Define the path of the Typescript file') .option('-o, --output ', 'Define the path of the output file. If not defined, it\'ll output on the STDOUT')