From 104a6cf3c9aa0fdfe4eab129f9c1900e1eb8f7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eligio=20Mari=C3=B1o?= <22875166+gmeligio@users.noreply.github.com> Date: Sat, 12 Apr 2025 11:19:35 +0200 Subject: [PATCH] fix(install): install in temp path instead of user working dir (#51) * fix: install and run binary from action path instead of working dir * refactor: use INSTALL_DIR * refactor: remove GIT_CLIFF_DIR and INSTALL_DIR --- install.sh | 12 ++++++++---- run.sh | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 42a817d..de37d13 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ fi set -euo pipefail ARCHIVE_EXT='tar.gz' -ARCHVIE_CMD='tar -xf' +ARCHIVE_CMD='tar -xf' GIT_CLIFF_BIN='git-cliff' case "${RUNNER_OS}" in @@ -17,7 +17,7 @@ case "${RUNNER_OS}" in Windows) OS=pc-windows-msvc ARCHIVE_EXT='zip' - ARCHVIE_CMD='7z x -aoa' + ARCHIVE_CMD='7z x -aoa' GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe" ;; *) @@ -31,6 +31,10 @@ case "${RUNNER_ARCH}" in *) ARCH=x86_64 ;; esac +INSTALL_DIR="$RUNNER_TEMP/git-cliff" +mkdir -p "$INSTALL_DIR" +cd "$INSTALL_DIR" + echo "git-cliff-${ARCH}-${OS}.${ARCHIVE_EXT}" RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest' @@ -69,8 +73,8 @@ if [[ ! -e "$TARGET" ]]; then echo "Downloading ${TARGET}..." curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION" echo "Unpacking ${TARGET}..." - ${ARCHVIE_CMD} "$TARGET" - mv git-cliff-${TAG_NAME:1}/${GIT_CLIFF_BIN} ./bin/${GIT_CLIFF_BIN} + ${ARCHIVE_CMD} "$TARGET" + mv git-cliff-${TAG_NAME:1}/${GIT_CLIFF_BIN} "./bin/$GIT_CLIFF_BIN" else echo "Using cached git-cliff binary." fi diff --git a/run.sh b/run.sh index dd42b0f..f8acc22 100755 --- a/run.sh +++ b/run.sh @@ -11,6 +11,8 @@ if [[ "${RUNNER_OS}" == 'Windows' ]]; then GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe" fi +GIT_CLIFF_PATH="$RUNNER_TEMP/git-cliff/bin/$GIT_CLIFF_BIN" + # Set up working directory owner=$(stat -c "%u:%g" .) chown -R "$(id -u)" . @@ -23,12 +25,12 @@ mkdir -p "$(dirname $OUTPUT)" args=$(echo "$@" | xargs) # Execute git-cliff -GIT_CLIFF_OUTPUT="$OUTPUT" ./bin/${GIT_CLIFF_BIN} $args +GIT_CLIFF_OUTPUT="$OUTPUT" "$GIT_CLIFF_PATH" $args exit_code=$? # Retrieve context CONTEXT="$(mktemp)" -GIT_CLIFF_OUTPUT="$CONTEXT" ./bin/${GIT_CLIFF_BIN} --context $args +GIT_CLIFF_OUTPUT="$CONTEXT" "$GIT_CLIFF_PATH" --context $args # Revert permissions chown -R "$owner" .