Skip to content

Commit 8796d68

Browse files
committed
chore: improve brew version parsing and installation in actions
1 parent f6de82e commit 8796d68

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

.github/actions/pristine-homebrew/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
"$prefix/sbin" "$prefix/share" "$prefix/var" "$prefix/Library/Taps"
2626
echo 'EOF'
2727
} >>"$GITHUB_OUTPUT"
28-
echo version=$(brew --version | sed -n '1{s/[<>:"\/\\|?*[:space:]]/_/g;p}') >> "$GITHUB_OUTPUT"
28+
echo version=$(brew --version | sed -e '1s/[<>:"\/\\|?* \t]/_/g' -e '2,$d') >> "$GITHUB_OUTPUT"
2929
- name: Cache lookup
3030
id: cache_lookup
3131
uses: actions/cache/restore@v4

.github/actions/setup-homebrew/action.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,12 @@ runs:
99
shell: bash
1010
run: |
1111
# Linuxbrew
12-
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
13-
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
12+
for path in "/home/linuxbrew/.linuxbrew/bin" "/opt/homebrew/bin" "/usr/local/bin";do
13+
if [ -x "$path/brew" ]; then
14+
eval "$("$path/brew" shellenv)"
15+
echo "$path/brew" >>"$GITHUB_PATH"
16+
fi
1417
fi
15-
# macOS Apple Silicon
16-
if [ -x /opt/homebrew/bin/brew ]; then
17-
eval "$(/opt/homebrew/bin/brew shellenv)"
18-
fi
19-
# macOS Intel
20-
if [ -x /usr/local/bin/brew ]; then
21-
eval "$(/usr/local/bin/brew shellenv)"
22-
fi
23-
24-
if ! command -v brew >/dev/null; then
25-
echo "::error::brew not found"
26-
exit 1
27-
fi
28-
29-
# Persist any new PATH entries for later steps
30-
ORIGINAL_PATH="$PATH"
31-
IFS=':' read -ra NEW_PARTS <<<"$PATH"
32-
for p in "${NEW_PARTS[@]}"; do
33-
case ":$ORIGINAL_PATH:" in
34-
*":$p:"*) ;; # already present
35-
*) echo "$p" >>"$GITHUB_PATH" ;;
36-
esac
37-
done
3818
3919
# Keep HOMEBREW variables
4020
echo "HOMEBREW_PREFIX=$(brew --prefix)" >> "$GITHUB_ENV"

0 commit comments

Comments
 (0)