image: node:latest

pipelines:
  branches:
    master:
      - step:
          caches:
            - node
          script:
            - apt-get update
            # Generates a .npmrc file configured for installing private modules:
            #
            # NPM_REGISTRY_URL: the full URL of your private registry
            #                   defaults to registry.npmjs.org.
            # NPM_TOKEN: secret token for installing private modules. This
            #            this token can be found in your .npmrc, after logging in.
            - 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
            - rm -rf ./dist && npm run build
            - npx semantic-release --debug