#!/bin/sh
set -e

eval "$(ssh-agent -s)"
echo "$GITLAB_SSH_KEY" | ssh-add -
mkdir -p ~/.ssh
chmod 400 ~/.ssh
ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts


export CI_PUSH_REPO="git@gitlab.com:${CI_PROJECT_PATH}.git"
echo $CI_PUSH_REPO
git remote set-url --push origin $CI_PUSH_REPO
git reset --hard
git clean -fd
git checkout $CI_COMMIT_REF_NAME
git pull origin $CI_COMMIT_REF_NAME
git fetch --all --depth 50
git branch -r
echo "//registry.npmjs.org/:_authToken=${NPM_PUBLISH_TOKEN}" > .npmrc
cat .npmrc

yarn
cp release-scripts/master/release/.release-it.json .
cat .release-it.json
git remote -v
npm run release --ci --verbose --no-increment
