Repository navigation
69 lines (66 loc) · 2.83 KB
/
Copy pathupdate.yml
File metadata and controls
69 lines (66 loc) · 2.83 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
name: update
# Follows sjq's releases: when the latest release is newer than the formula
# and has all its binaries, the formula is regenerated (with sjq's current
# scripts/package_manifests.py), checked by Homebrew and committed.
on:
schedule:
- cron: '17 */6 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
sjq:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Compare with the latest release
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
latest=$(gh release view --repo simdjson/sjq --json tagName --jq .tagName)
current=$(grep -o 'releases/download/v[^/]*' Formula/sjq.rb | head -1 | sed 's|releases/download/||')
echo "latest $latest, formula $current"
if [ "$latest" = "$current" ]; then
echo "update=false" >> "$GITHUB_OUTPUT"
exit 0
fi
curl -fsSL -o "$RUNNER_TEMP/package_manifests.py" \
"https://raw.githubusercontent.com/simdjson/sjq/main/scripts/package_manifests.py"
python3 "$RUNNER_TEMP/package_manifests.py" "$latest" "$RUNNER_TEMP/packaging"
if [ ! -f "$RUNNER_TEMP/packaging/homebrew/sjq.rb" ]; then
echo "$latest does not have all its binaries yet"
echo "update=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "update=true" >> "$GITHUB_OUTPUT"
echo "tag=$latest" >> "$GITHUB_OUTPUT"
# setup-homebrew taps this repository as simdjson/tap and resets the
# checkout: it comes first, then the new formula is committed, checked,
# and pushed only if Homebrew accepts it.
- name: Set up Homebrew
if: steps.check.outputs.update == 'true'
uses: Homebrew/actions/setup-homebrew@main
- name: Commit locally
if: steps.check.outputs.update == 'true'
run: |
cp "$RUNNER_TEMP/packaging/homebrew/sjq.rb" Formula/sjq.rb
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "sjq ${{ steps.check.outputs.tag }}"
grep -m1 'releases/download' Formula/sjq.rb
- name: Check the new formula
if: steps.check.outputs.update == 'true'
run: |
brew trust simdjson/tap
brew audit --strict simdjson/tap/sjq
brew install simdjson/tap/sjq
brew test simdjson/tap/sjq
tag="${{ steps.check.outputs.tag }}"
"$(brew --prefix)/bin/sjq" --version | grep -F "sjq ${tag#v} "
# setup-homebrew drops the credentials that checkout stored.
- name: Push
if: steps.check.outputs.update == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: git push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:main