#! /bin/bash
set -e

if ! ping -c1 npm.pkgs.xarth.tv > /dev/null 2>&1; then
  echo 'Could not reach https://npm.pkgs.xarth.tv'
  echo 'You must be on the Twitch VPN (Viscosity) to publish'
  exit 1
fi

git fetch origin
git checkout publish
git reset --hard origin/main
git push origin publish -f

yarn build:packages
lerna publish --pre-dist-tag pre

echo 'Publish complete.'
echo 'Follow the post-publish docs to complete the process:'
echo 'https://git.xarth.tv/pages/emerging-platforms/tachyon/d/internal-docs/processes/publishing-tachyon/#after-publishing'
