github.com/anchore/syft@v1.38.2/.github/scripts/trigger-release.sh (about) 1 #!/usr/bin/env bash 2 set -eu 3 4 bold=$(tput bold) 5 normal=$(tput sgr0) 6 7 GH_CLI=.tool/gh 8 9 if ! [ -x "$(command -v $GH_CLI)" ]; then 10 echo "The GitHub CLI could not be found. run: make bootstrap" 11 exit 1 12 fi 13 14 $GH_CLI auth status 15 16 # set the default repo in cases where multiple remotes are defined 17 $GH_CLI repo set-default anchore/syft 18 19 export GITHUB_TOKEN="${GITHUB_TOKEN-"$($GH_CLI auth token)"}" 20 21 # we need all of the git state to determine the next version. Since tagging is done by 22 # the release pipeline it is possible to not have all of the tags from previous releases. 23 git fetch --tags 24 25 # populates the CHANGELOG.md and VERSION files 26 echo "${bold}Generating changelog...${normal}" 27 make changelog 2> /dev/null 28 29 NEXT_VERSION=$(cat VERSION) 30 31 if [[ "$NEXT_VERSION" == "" || "${NEXT_VERSION}" == "(Unreleased)" ]]; then 32 echo "Could not determine the next version to release. Exiting..." 33 exit 1 34 fi 35 36 while true; do 37 read -p "${bold}Do you want to trigger a release for version '${NEXT_VERSION}'?${normal} [y/n] " yn 38 case $yn in 39 [Yy]* ) echo; break;; 40 [Nn]* ) echo; echo "Cancelling release..."; exit;; 41 * ) echo "Please answer yes or no.";; 42 esac 43 done 44 45 echo "${bold}Kicking off release for ${NEXT_VERSION}${normal}..." 46 echo 47 $GH_CLI workflow run release.yaml -f version=${NEXT_VERSION} 48 49 echo 50 echo "${bold}Waiting for release to start...${normal}" 51 sleep 10 52 53 set +e 54 55 echo "${bold}Head to the release workflow to monitor the release:${normal} $($GH_CLI run list --workflow=release.yaml --limit=1 --json url --jq '.[].url')" 56 id=$($GH_CLI run list --workflow=release.yaml --limit=1 --json databaseId --jq '.[].databaseId') 57 $GH_CLI run watch $id --exit-status || (echo ; echo "${bold}Logs of failed step:${normal}" && GH_PAGER="" $GH_CLI run view $id --log-failed)