mirror of
https://github.com/orhun/git-cliff-action.git
synced 2026-03-22 15:35:44 +08:00
refactor(install): trim the install output
This commit is contained in:
19
install.sh
19
install.sh
@@ -1,6 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -uxo pipefail
|
if [[ -n "$DEBUG" ]]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
case "${RUNNER_OS}" in
|
case "${RUNNER_OS}" in
|
||||||
macOS) OS=apple-darwin ;;
|
macOS) OS=apple-darwin ;;
|
||||||
@@ -18,6 +22,7 @@ RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest'
|
|||||||
if [[ "${VERSION}" != 'latest' ]]; then
|
if [[ "${VERSION}" != 'latest' ]]; then
|
||||||
RELEASE_URL="https://api.github.com/repos/orhun/git-cliff/releases/tags/${VERSION}"
|
RELEASE_URL="https://api.github.com/repos/orhun/git-cliff/releases/tags/${VERSION}"
|
||||||
fi
|
fi
|
||||||
|
echo "Downloading git-cliff ${VERSION} from ${RELEASE_URL}"
|
||||||
|
|
||||||
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
|
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
|
||||||
if [[ -z "${GITHUB_API_TOKEN}" ]]; then
|
if [[ -z "${GITHUB_API_TOKEN}" ]]; then
|
||||||
@@ -36,16 +41,22 @@ fi
|
|||||||
|
|
||||||
TAG_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".tag_name")"
|
TAG_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".tag_name")"
|
||||||
TARGET="git-cliff-${TAG_NAME:1}-${ARCH}-${OS}.tar.gz"
|
TARGET="git-cliff-${TAG_NAME:1}-${ARCH}-${OS}.tar.gz"
|
||||||
LOCATION="$(echo "${RELEASE_INFO}" \
|
LOCATION="$(echo "${RELEASE_INFO}" |
|
||||||
| jq --raw-output ".assets[].browser_download_url" \
|
jq --raw-output ".assets[].browser_download_url" |
|
||||||
| grep "${TARGET}$")"
|
grep "${TARGET}$")"
|
||||||
|
echo "Found release: ${LOCATION}"
|
||||||
|
|
||||||
# Create bin directory
|
# Create bin directory
|
||||||
mkdir -p ./bin
|
mkdir -p ./bin
|
||||||
|
|
||||||
# Skip downloading release if downloaded already, e.g. when the action is used multiple times.
|
# Skip downloading release if downloaded already, e.g. when the action is used multiple times.
|
||||||
if [[ ! -e "$TARGET" ]]; then
|
if [[ ! -e "$TARGET" ]]; then
|
||||||
|
echo "Downloading ${TARGET}..."
|
||||||
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION"
|
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION"
|
||||||
tar -xf "$TARGET"
|
tar -xf "$TARGET"
|
||||||
mv git-cliff-${TAG_NAME:1}/git-cliff ./bin/git-cliff
|
mv git-cliff-${TAG_NAME:1}/git-cliff ./bin/git-cliff
|
||||||
|
else
|
||||||
|
echo "Using cached git-cliff binary."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "git-cliff is ready to use!"
|
||||||
|
|||||||
Reference in New Issue
Block a user