From 11bd174d2bc134660a9cd7825c375b37cf4965c1 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 May 2024 21:16:19 +0300 Subject: [PATCH] chore(scripts): add custom gh auth to release script --- scripts/release.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/release.sh b/scripts/release.sh index c2500aee2ec7d..06a690a0dcbeb 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -113,6 +113,18 @@ done # Check dependencies. dependencies gh jq sort +# Authenticate gh CLI. +# NOTE: Coder external-auth won't work because the GitHub App lacks permissions. +if [[ -z ${GITHUB_TOKEN:-} ]]; then + if [[ -n ${GH_TOKEN:-} ]]; then + export GITHUB_TOKEN=${GH_TOKEN} + elif token="$(gh auth token --hostname github.com 2>/dev/null)"; then + export GITHUB_TOKEN=${token} + else + error "GitHub authentication is required to run this command, please set GITHUB_TOKEN or run 'gh auth login'." + fi +fi + if [[ -z $increment ]]; then # Default to patch versions. increment="patch"