Skip to content

Commit a39e27f

Browse files
authored
fix(run): update stat cmd for cross-platform compatibility (#66)
1 parent d77b37d commit a39e27f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

run.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ fi
1717

1818
GIT_CLIFF_PATH="$RUNNER_TEMP/git-cliff/bin/$GIT_CLIFF_BIN"
1919

20+
# On Darwin, BSD stat is the default
21+
# otherwise is GNU stat
22+
if [[ "${RUNNER_OS}" == "macOS" ]]; then
23+
stat_cmd=(stat -f)
24+
else
25+
stat_cmd=(stat -c)
26+
fi
27+
2028
# Set up working directory
21-
owner=$(stat -c "%u:%g" .)
29+
owner=$("${stat_cmd}" "%u:%g" .)
2230
chown -R "$(id -u)" .
2331

2432
# Create the output directory
@@ -58,7 +66,7 @@ GIT_CLIFF_OUTPUT="$CONTEXT" "$GIT_CLIFF_PATH" --context "${args[@]}"
5866
chown -R "$owner" .
5967

6068
# Set the changelog content (max: 50MB)
61-
FILESIZE=$(stat -c%s "$OUTPUT")
69+
FILESIZE=$("${stat_cmd}" %s "$OUTPUT")
6270
MAXSIZE=$((40 * 1024 * 1024))
6371
if [ "$FILESIZE" -le "$MAXSIZE" ]; then
6472
echo "content<<EOF" >>$GITHUB_OUTPUT

0 commit comments

Comments
 (0)