fix(run): update stat cmd for cross-platform compatibility (#66)

This commit is contained in:
MGSousa
2025-10-25 18:55:34 +01:00
committed by GitHub
parent d77b37db2e
commit a39e27f550

12
run.sh
View File

@@ -17,8 +17,16 @@ fi
GIT_CLIFF_PATH="$RUNNER_TEMP/git-cliff/bin/$GIT_CLIFF_BIN" GIT_CLIFF_PATH="$RUNNER_TEMP/git-cliff/bin/$GIT_CLIFF_BIN"
# On Darwin, BSD stat is the default
# otherwise is GNU stat
if [[ "${RUNNER_OS}" == "macOS" ]]; then
stat_cmd=(stat -f)
else
stat_cmd=(stat -c)
fi
# Set up working directory # Set up working directory
owner=$(stat -c "%u:%g" .) owner=$("${stat_cmd}" "%u:%g" .)
chown -R "$(id -u)" . chown -R "$(id -u)" .
# Create the output directory # Create the output directory
@@ -58,7 +66,7 @@ GIT_CLIFF_OUTPUT="$CONTEXT" "$GIT_CLIFF_PATH" --context "${args[@]}"
chown -R "$owner" . chown -R "$owner" .
# Set the changelog content (max: 50MB) # Set the changelog content (max: 50MB)
FILESIZE=$(stat -c%s "$OUTPUT") FILESIZE=$("${stat_cmd}" %s "$OUTPUT")
MAXSIZE=$((40 * 1024 * 1024)) MAXSIZE=$((40 * 1024 * 1024))
if [ "$FILESIZE" -le "$MAXSIZE" ]; then if [ "$FILESIZE" -le "$MAXSIZE" ]; then
echo "content<<EOF" >>$GITHUB_OUTPUT echo "content<<EOF" >>$GITHUB_OUTPUT