#!/bin/bash -e

echo "Setting publish config for scope '@$CI_PROJECT_ROOT_NAMESPACE', project id '$CI_PROJECT_ID'"
npm config set "@$CI_PROJECT_ROOT_NAMESPACE:registry" "$CI_SERVER_URL/api/v4/packages/npm"
npm config set "//$CI_SERVER_HOST/api/v4/packages/npm/:_authToken" "$CI_JOB_TOKEN"
npm config set "//$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/npm/:_authToken" "$CI_JOB_TOKEN"

echo "Publishing package '@$CI_PROJECT_ROOT_NAMESPACE/$CI_PROJECT_NAME' to internal package registry"
npm publish

echo "Done!"