variables:
  NPM_REGISTRY_SCOPE:
    value: wpdesk
    options:
      - wpdesk
      - octolize
    description: The scope of the npm registry

npm:publish:
  image: node:20.18-slim
  stage: deploy
  rules:
    - if: $IS_NPM_LIBRARY && $CI_COMMIT_TAG
  script:
    - echo "@${NPM_REGISTRY_SCOPE}:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
    - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
    - npm publish
