Skip to content

Commit 4a4a951

Browse files
authored
fix(install): fix running on windows host (#43)
Co-authored-by: Yegor Bayev <[email protected]>
1 parent e364f07 commit 4a4a951

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

install.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ if [[ -n "$DEBUG" ]]; then
44
set -x
55
fi
66

7-
set -uo pipefail
7+
set -euo pipefail
88

9-
ARCHIVE_EXT='.tar.gz'
9+
ARCHIVE_EXT='tar.gz'
10+
ARCHVIE_CMD='tar -xf'
11+
GIT_CLIFF_BIN='git-cliff'
1012

1113
case "${RUNNER_OS}" in
1214
macOS)
1315
OS=apple-darwin
1416
;;
1517
Windows)
1618
OS=pc-windows-msvc
17-
ARCHIVE_EXT='.zip'
19+
ARCHIVE_EXT='zip'
20+
ARCHVIE_CMD='7z x -aoa'
21+
GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe"
1822
;;
1923
*)
2024
OS=unknown-linux-gnu
@@ -27,11 +31,13 @@ case "${RUNNER_ARCH}" in
2731
*) ARCH=x86_64 ;;
2832
esac
2933

34+
echo "git-cliff-${ARCH}-${OS}.${ARCHIVE_EXT}"
35+
3036
RELEASE_URL='https://api.github.com/repos/orhun/git-cliff/releases/latest'
3137
if [[ "${VERSION}" != 'latest' ]]; then
3238
RELEASE_URL="https://api.github.com/repos/orhun/git-cliff/releases/tags/${VERSION}"
3339
fi
34-
echo "Downloading git-cliff ${VERSION} from ${RELEASE_URL}"
40+
echo "Getting git-cliff ${VERSION} from ${RELEASE_URL}"
3541

3642
# Caching is disabled in order not to receive stale responses from Varnish cache fronting GitHub API.
3743
if [[ -z "${GITHUB_API_TOKEN}" ]]; then
@@ -49,7 +55,7 @@ else
4955
fi
5056

5157
TAG_NAME="$(echo "${RELEASE_INFO}" | jq --raw-output ".tag_name")"
52-
TARGET="git-cliff-${TAG_NAME:1}-${ARCH}-${OS}${ARCHIVE_EXT}"
58+
TARGET="git-cliff-${TAG_NAME:1}-${ARCH}-${OS}.${ARCHIVE_EXT}"
5359
LOCATION="$(echo "${RELEASE_INFO}" |
5460
jq --raw-output ".assets[].browser_download_url" |
5561
grep "${TARGET}$")"
@@ -62,8 +68,9 @@ mkdir -p ./bin
6268
if [[ ! -e "$TARGET" ]]; then
6369
echo "Downloading ${TARGET}..."
6470
curl --silent --show-error --fail --location --output "$TARGET" "$LOCATION"
65-
tar -xf "$TARGET"
66-
mv git-cliff-${TAG_NAME:1}/git-cliff ./bin/git-cliff
71+
echo "Unpacking ${TARGET}..."
72+
${ARCHVIE_CMD} "$TARGET"
73+
mv git-cliff-${TAG_NAME:1}/${GIT_CLIFF_BIN} ./bin/${GIT_CLIFF_BIN}
6774
else
6875
echo "Using cached git-cliff binary."
6976
fi

run.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ set -uxo pipefail
55
# Avoid file expansion when passing parameters like with '*'
66
set -o noglob
77

8+
GIT_CLIFF_BIN='git-cliff'
9+
10+
if [[ "${RUNNER_OS}" == 'Windows' ]]; then
11+
GIT_CLIFF_BIN="${GIT_CLIFF_BIN}.exe"
12+
fi
13+
814
# Set up working directory
915
owner=$(stat -c "%u:%g" .)
1016
chown -R "$(id -u)" .
@@ -17,12 +23,12 @@ mkdir -p "$(dirname $OUTPUT)"
1723
args=$(echo "$@" | xargs)
1824

1925
# Execute git-cliff
20-
GIT_CLIFF_OUTPUT="$OUTPUT" ./bin/git-cliff $args
26+
GIT_CLIFF_OUTPUT="$OUTPUT" ./bin/${GIT_CLIFF_BIN} $args
2127
exit_code=$?
2228

2329
# Retrieve context
2430
CONTEXT="$(mktemp)"
25-
GIT_CLIFF_OUTPUT="$CONTEXT" ./bin/git-cliff $args --context
31+
GIT_CLIFF_OUTPUT="$CONTEXT" ./bin/${GIT_CLIFF_BIN} $args --context
2632

2733
# Revert permissions
2834
chown -R "$owner" .
@@ -31,10 +37,10 @@ chown -R "$owner" .
3137
FILESIZE=$(stat -c%s "$OUTPUT")
3238
MAXSIZE=$((40 * 1024 * 1024))
3339
if [ "$FILESIZE" -le "$MAXSIZE" ]; then
34-
echo "content<<EOF" >>$GITHUB_OUTPUT
35-
cat "$OUTPUT" >>$GITHUB_OUTPUT
36-
echo "EOF" >>$GITHUB_OUTPUT
37-
cat "$OUTPUT"
40+
echo "content<<EOF" >>$GITHUB_OUTPUT
41+
cat "$OUTPUT" >>$GITHUB_OUTPUT
42+
echo "EOF" >>$GITHUB_OUTPUT
43+
cat "$OUTPUT"
3844
fi
3945

4046
# Set output file

0 commit comments

Comments
 (0)