-
Notifications
You must be signed in to change notification settings - Fork 14
94 lines (85 loc) · 3.41 KB
/
homebrew-publish.yml
File metadata and controls
94 lines (85 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Homebrew 发布
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
update-homebrew-tap:
runs-on: ubuntu-latest
env:
HOMEBREW_TAP_REPOSITORY: iFurySt/homebrew-open-browser-use
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Render and publish Homebrew formula
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ -z "${HOMEBREW_TAP_TOKEN}" ]; then
echo "HOMEBREW_TAP_TOKEN is required to update ${HOMEBREW_TAP_REPOSITORY}" >&2
exit 1
fi
version="${GITHUB_REF_NAME#v}"
assets_dir="$(mktemp -d)"
required_assets=(
"open-browser-use-cli-${version}-darwin-amd64.tar.gz"
"open-browser-use-cli-${version}-darwin-arm64.tar.gz"
"open-browser-use-cli-${version}-linux-amd64.tar.gz"
"open-browser-use-cli-${version}-linux-arm64.tar.gz"
)
for attempt in $(seq 1 60); do
rm -f "${assets_dir}"/*.tar.gz
if gh release download "${GITHUB_REF_NAME}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern "open-browser-use-cli-${version}-*.tar.gz" \
--dir "${assets_dir}" \
--clobber >/dev/null 2>&1; then
all_assets_ready=true
for asset in "${required_assets[@]}"; do
if [ ! -f "${assets_dir}/${asset}" ]; then
all_assets_ready=false
break
fi
done
if [ "${all_assets_ready}" = true ]; then
break
fi
fi
if [ "${attempt}" -eq 60 ]; then
echo "Timed out waiting for CLI release archives on ${GITHUB_REF_NAME}" >&2
exit 1
fi
sleep 10
done
sha_for() {
sha256sum "${assets_dir}/$1" | awk '{print $1}'
}
darwin_amd64_sha256="$(sha_for "open-browser-use-cli-${version}-darwin-amd64.tar.gz")"
darwin_arm64_sha256="$(sha_for "open-browser-use-cli-${version}-darwin-arm64.tar.gz")"
linux_amd64_sha256="$(sha_for "open-browser-use-cli-${version}-linux-amd64.tar.gz")"
linux_arm64_sha256="$(sha_for "open-browser-use-cli-${version}-linux-arm64.tar.gz")"
tmp_dir="$(mktemp -d)"
trap 'rm -rf "${tmp_dir}" "${assets_dir}"' EXIT
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/${HOMEBREW_TAP_REPOSITORY}.git" "${tmp_dir}/tap"
mkdir -p "${tmp_dir}/tap/Formula"
./scripts/render-homebrew-formula.sh \
"${version}" \
"${darwin_amd64_sha256}" \
"${darwin_arm64_sha256}" \
"${linux_amd64_sha256}" \
"${linux_arm64_sha256}" \
> "${tmp_dir}/tap/Formula/open-browser-use.rb"
cd "${tmp_dir}/tap"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/open-browser-use.rb
if git diff --cached --quiet; then
echo "Homebrew formula already up to date"
exit 0
fi
git commit -m "Update open-browser-use to ${GITHUB_REF_NAME}"
git push origin HEAD:main