From 8a757e0486710f2542e0e3377083d3c595c41436 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 8 Sep 2021 17:01:16 +0200 Subject: [PATCH] push-release.sh: improve --dry-run mode - Don't require OAUTH_TOKEN - Skip interactive query --- helper/push-release.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/helper/push-release.sh b/helper/push-release.sh index 9058214..4a3ec46 100755 --- a/helper/push-release.sh +++ b/helper/push-release.sh @@ -3,14 +3,10 @@ set -euo pipefail REPO=fort-nix/nix-bitcoin BRANCH=master -OAUTH_TOKEN=$(pass show nix-bitcoin/github/oauth-token) +OAUTH_TOKEN= DRY_RUN= TAG_NAME= -if [[ ! $OAUTH_TOKEN ]]; then - echo "Please set OAUTH_TOKEN variable" -fi - for arg in "$@"; do case $arg in --dry-run|-n) @@ -26,18 +22,28 @@ if [[ ! $TAG_NAME ]]; then echo "$0 [--dry-run|-n] " exit fi -if [[ $DRY_RUN ]]; then echo "Dry run"; fi +if [[ $DRY_RUN ]]; then + echo "Dry run" +else + OAUTH_TOKEN=$(pass show nix-bitcoin/github/oauth-token) + if [[ ! $OAUTH_TOKEN ]]; then + echo "Please set OAUTH_TOKEN variable" + fi +fi RESPONSE=$(curl https://api.github.com/repos/$REPO/releases/latest 2> /dev/null) echo "Latest release" $(echo $RESPONSE | jq -r '.tag_name' | tail -c +2) -while true; do - read -p "Create release $TAG_NAME? [yn] " yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer y or n.";; - esac -done + +if [[ ! $DRY_RUN ]]; then + while true; do + read -p "Create release $TAG_NAME? [yn] " yn + case $yn in + [Yy]* ) break;; + [Nn]* ) exit;; + * ) echo "Please answer y or n.";; + esac + done +fi TMPDIR=$(mktemp -d) if [[ ! $DRY_RUN ]]; then trap "rm -rf $TMPDIR" EXIT; fi