Skip to content

Commit 6077e2e

Browse files
committed
chore: Refactor pristine-homebrew action to improve path handling and brew version detection
1 parent f6e49b3 commit 6077e2e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,39 @@ inputs:
1313
runs:
1414
using: composite
1515
steps:
16-
- name: Build path list
17-
id: brew_paths
16+
- name: Build path list and check brew version
17+
id: brew
1818
shell: bash
1919
run: |
20-
P="${{ steps.brew_env.outputs.prefix }}"
20+
prefix="$(brew --prefix)"
2121
{
2222
echo 'list<<EOF'
2323
printf '%s\n' \
24-
"$P/bin" "$P/etc" "$P/include" "$P/lib" "$P/opt" \
25-
"$P/sbin" "$P/share" "$P/var" "$P/Library/Taps"
24+
"$prefix/bin" "$prefix/etc" "$prefix/include" "$prefix/lib" "$prefix/opt" \
25+
"$prefix/sbin" "$prefix/share" "$prefix/var" "$prefix/Library/Taps"
2626
echo 'EOF'
2727
} >>"$GITHUB_OUTPUT"
28+
version=$(brew --version)
2829
- name: Cache lookup
2930
id: cache_lookup
3031
uses: actions/cache/restore@v4
3132
with:
3233
lookup-only: true
33-
path: ${{ steps.brew_paths.outputs.list }}
34-
key: brew-pristine-${{ inputs.os }}-${{ steps.brew_env.outputs.version }}
34+
path: ${{ steps.brew.outputs.list }}
35+
key: brew-pristine-${{ inputs.os }}-${{ steps.brew.outputs.version }}
3536
- name: Remove current Homebrew directories
3637
if: inputs.restore == 'true' && steps.cache_lookup.outputs.cache-hit == 'true'
3738
shell: bash
3839
run: |
3940
while read -r d; do
4041
rm -rf "$d"
41-
done <<<"${{ steps.brew_paths.outputs.list }}"
42+
done <<<"${{ steps.brew.outputs.list }}"
4243
- name: Restore pristine Homebrew
4344
id: cache_restore
4445
if: inputs.restore == 'true' && steps.cache_lookup.outputs.cache-hit == 'true'
4546
uses: actions/cache/restore@v4
4647
with:
47-
path: ${{ steps.brew_paths.outputs.list }}
48+
path: ${{ steps.brew.outputs.list }}
4849
key: ${{ steps.cache_lookup.outputs.cache-primary-key }}
4950
- name: Make Homebrew pristine
5051
if: steps.cache_lookup.outputs.cache-hit != 'true'
@@ -79,8 +80,8 @@ runs:
7980
if: steps.cache_lookup.outputs.cache-hit != 'true'
8081
uses: actions/cache/save@v4
8182
with:
82-
path: ${{ steps.brew_paths.outputs.list }}
83-
key: brew-pristine-${{ inputs.os }}-${{ steps.brew_env.outputs.version }}
83+
path: ${{ steps.brew.outputs.list }}
84+
key: brew-pristine-${{ inputs.os }}-${{ steps.brew.outputs.version }}
8485
- name: Remove brew download cache
8586
if: inputs.restore == 'true'
8687
shell: bash

0 commit comments

Comments
 (0)