image: node:8.9.0

pipelines:
  default:
    - step:
        caches:
          - node
        script:
          - declare -x VERSION=$(node -e 'console.log(require("./package.json").version)')
          - echo building v$VERSION
          - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
          - npm install
          - npm run build
          - npm publish
          - git tag $VERSION
          - git push origin --tags
