From 5fb231774c2d7467adf66eb3fde8b9d42f442b5d Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 May 2024 21:37:04 +0300 Subject: [PATCH] chore(scripts): add custom gh auth to release script (#13396) --- scripts/release.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/release.sh b/scripts/release.sh index 3847ea7ca0..e3a642e19e 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"