mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-10-29 21:53:43 +00:00
ci: cache Homebrew tool downloads
This commit is contained in:
@@ -26,9 +26,48 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Prepare Homebrew download cache
|
||||
id: homebrew-cache-key
|
||||
run: |
|
||||
brew info --json=v2 age go-task xcodegen swiftlint > "$RUNNER_TEMP/homebrew-formulae.json"
|
||||
formula_hash=$(python3 - "$RUNNER_TEMP/homebrew-formulae.json" <<'PY'
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
|
||||
with open(sys.argv[1]) as source:
|
||||
formulae = json.load(source)["formulae"]
|
||||
versions = sorted(
|
||||
(f["full_name"], f["versions"]["stable"], f["revision"], f["bottle"])
|
||||
for f in formulae
|
||||
)
|
||||
print(hashlib.sha256(json.dumps(versions, sort_keys=True).encode()).hexdigest())
|
||||
PY
|
||||
)
|
||||
echo "path=$(brew --cache)/downloads" >> "$GITHUB_OUTPUT"
|
||||
echo "key=ng2-homebrew-downloads-v1-macos-$(sw_vers -productVersion)-$(uname -m)-$formula_hash" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore Homebrew download cache
|
||||
id: homebrew-cache
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ steps.homebrew-cache-key.outputs.path }}
|
||||
key: ${{ steps.homebrew-cache-key.outputs.key }}
|
||||
|
||||
- name: Install build tools and test dependencies
|
||||
id: install-build-tools
|
||||
env:
|
||||
HOMEBREW_NO_AUTO_UPDATE: '1'
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: '1'
|
||||
run: brew install age go-task xcodegen swiftlint
|
||||
|
||||
- name: Save Homebrew download cache
|
||||
if: steps.install-build-tools.outcome == 'success' && steps.homebrew-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ steps.homebrew-cache-key.outputs.path }}
|
||||
key: ${{ steps.homebrew-cache-key.outputs.key }}
|
||||
|
||||
- name: Restore external binary archive cache
|
||||
id: external-binary-cache
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
|
||||
Reference in New Issue
Block a user