stages:
  - compile
  - publish

compile:
  image: node:latest
  stage: compile
  script:
    - yarn set version 4
    - yarn
    - cd browserLibs && yarn && mv node_modules modules && cd ..
    - cd commonLibs && yarn && mv node_modules modules && cd ..
    - yarn run build || true
    - npm pack
    - ls -la
    - mv zarbis-*.tgz zarbis.npm.tgz
  artifacts:
    paths:
      - ./*.npm.tgz
    expire_in: 8 hours
  cache:
    paths:
      - ./.yarn
      - ./browserLibs/.yarn
      - ./commonLibs/.yarn

publish:
  image: node:latest
  stage: publish
  script:
    - echo $CI_NPM_TOKEN >> ~/.npmrc
    - echo "unsafe-perm = true" >> ~/.npmrc
    - find . | grep .npm.tgz | xargs -L 1 npm publish
  only:
    - tags
