stages:
  - publish-npm

publish_npm:
  image: "node:current-alpine"
  stage: publish-npm
  before_script:
    - apk add --update bash
    - apk add --update make
    - apk add --update protobuf-dev
    - apk add --update yarn

  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - config/package.json
  script:
    - npm install -g ts-proto@1.115.5
    - npm install -g typescript@4.7.4
    - make proto
    - cd ./config
    - NPM_PACKAGE_VERSION=$(node -p "require('./package.json').version")
    - yarn pub
    - echo "Successfully published version ${NPM_PACKAGE_VERSION} to GitLab's NPM registry"