#!/bin/sh
BASEDIR=$(dirname $0)

. $BASEDIR/../.env

echo deleting old release ${RELEASE_ORG_SLUG} ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty}
sentry-cli --url https://glitchtip.basehosts.de/ --auth-token ${GLITCHTIP_TOKEN} releases --org ${RELEASE_ORG_SLUG} --project ${RELEASE_PROJECT_SLUG} delete ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty}

echo creating release ${RELEASE_ORG_SLUG} ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty} and uploading sourcemaps
sentry-cli --url https://glitchtip.basehosts.de/ --auth-token ${GLITCHTIP_TOKEN} releases --org ${RELEASE_ORG_SLUG} --project ${RELEASE_PROJECT_SLUG} files ${RELEASE_VERSION:-$RELEASE_PROJECT_SLUG.dirty} upload-sourcemaps --url-prefix='~/' --ext js --ext mjs --ext svelte --ext map frontend
