mirror of
https://github.com/orhun/git-cliff-action.git
synced 2026-03-22 07:25:43 +08:00
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
This commit is contained in:
12
install.sh
12
install.sh
@@ -7,7 +7,7 @@ fi
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
ARCHIVE_EXT='tar.gz'
|
ARCHIVE_EXT='tar.gz'
|
||||||
ARCHVIE_CMD='tar -xf'
|
ARCHIVE_CMD='tar -xf'
|
||||||
GIT_CLIFF_BIN='git-cliff'
|
GIT_CLIFF_BIN='git-cliff'
|
||||||
|
|
||||||
case "${RUNNER_OS}" in
|
case "${RUNNER_OS}" in
|
||||||
@@ -17,7 +17,7 @@ case "${RUNNER_OS}" in
|
|||||||
Windows)
|
Windows)
|
||||||
OS=pc-windows-msvc
|
OS=pc-windows-msvc
|
||||||
ARCHIVE_EXT='zip'
|
ARCHIVE_EXT='zip'
|
||||||
ARCHVIE_CMD='7z x -aoa'
|
ARCHIVE_CMD='7z x -aoa'
|
||||||
GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe"
|
GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -31,6 +31,10 @@ case "${RUNNER_ARCH}" in
|
|||||||
*) ARCH=x86_64 ;;
|
*) ARCH=x86_64 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
INSTALL_DIR="$RUNNER_TEMP/git-cliff"
|
||||||
|
mkdir -p "$INSTALL_DIR"
|
||||||
|
cd "$INSTALL_DIR"
|
||||||
|
|
||||||
echo "git-cliff-${ARCH}-${OS}.${ARCHIVE_EXT}"
|
echo "git-cliff-${ARCH}-${OS}.${ARCHIVE_EXT}"
|
||||||
|
|
||||||
RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest'
|
RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest'
|
||||||
@@ -69,8 +73,8 @@ if [[ ! -e "$TARGET" ]]; then
|
|||||||
echo "Downloading ${TARGET}..."
|
echo "Downloading ${TARGET}..."
|
||||||
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION"
|
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION"
|
||||||
echo "Unpacking ${TARGET}..."
|
echo "Unpacking ${TARGET}..."
|
||||||
${ARCHVIE_CMD} "$TARGET"
|
${ARCHIVE_CMD} "$TARGET"
|
||||||
mv git-cliff-${TAG_NAME:1}/${GIT_CLIFF_BIN} ./bin/${GIT_CLIFF_BIN}
|
mv git-cliff-${TAG_NAME:1}/${GIT_CLIFF_BIN} "./bin/$GIT_CLIFF_BIN"
|
||||||
else
|
else
|
||||||
echo "Using cached git-cliff binary."
|
echo "Using cached git-cliff binary."
|
||||||
fi
|
fi
|
||||||
|
|||||||
6
run.sh
6
run.sh
@@ -11,6 +11,8 @@ if [[ "${RUNNER_OS}" == 'Windows' ]]; then
|
|||||||
GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe"
|
GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
GIT_CLIFF_PATH="$RUNNER_TEMP/git-cliff/bin/$GIT_CLIFF_BIN"
|
||||||
|
|
||||||
# Set up working directory
|
# Set up working directory
|
||||||
owner=$(stat -c "%u:%g" .)
|
owner=$(stat -c "%u:%g" .)
|
||||||
chown -R "$(id -u)" .
|
chown -R "$(id -u)" .
|
||||||
@@ -23,12 +25,12 @@ mkdir -p "$(dirname $OUTPUT)"
|
|||||||
args=$(echo "$@" | xargs)
|
args=$(echo "$@" | xargs)
|
||||||
|
|
||||||
# Execute git-cliff
|
# Execute git-cliff
|
||||||
GIT_CLIFF_OUTPUT="$OUTPUT" ./bin/${GIT_CLIFF_BIN} $args
|
GIT_CLIFF_OUTPUT="$OUTPUT" "$GIT_CLIFF_PATH" $args
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
|
||||||
# Retrieve context
|
# Retrieve context
|
||||||
CONTEXT="$(mktemp)"
|
CONTEXT="$(mktemp)"
|
||||||
GIT_CLIFF_OUTPUT="$CONTEXT" ./bin/${GIT_CLIFF_BIN} --context $args
|
GIT_CLIFF_OUTPUT="$CONTEXT" "$GIT_CLIFF_PATH" --context $args
|
||||||
|
|
||||||
# Revert permissions
|
# Revert permissions
|
||||||
chown -R "$owner" .
|
chown -R "$owner" .
|
||||||
|
|||||||
Reference in New Issue
Block a user