-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (71 loc) · 3.74 KB
/
algorand-updater.yml
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
name: Check and Update Algorand Version
on:
schedule:
- cron: "0 0,12 * * *" # Runs at 00:00 and 12:00 UTC every day
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
check-and-update-algorand-version:
runs-on: macos-15
concurrency:
group: algorand-updater
cancel-in-progress: false
steps:
- name: Checkout homebrew-tap repository
uses: actions/checkout@v4
- name: Get version from algorand.rb
id: get_version
run: |
current_version=$(grep -E '^\s*url\s+"https://github.com/algorand/go-algorand/releases/download/v[0-9]+\.[0-9]+\.[0-9]+-stable/node_stable_darwin-universal_[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz"' Formula/algorand.rb | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/^v//')
echo "current_version=$current_version" >> "$GITHUB_OUTPUT"
- name: Fetch latest go-algorand stable tag
id: fetch_tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/algorand/go-algorand/tags")
latest_tag=$(echo "$response" | jq -r '[.[] | select(.name | contains("-stable"))][0].name' | sed 's/^v//; s/-stable$//')
if [ -z "$latest_tag" ]; then
echo "Error: Failed to fetch the latest stable tag."
exit 1
fi
echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT"
- name: Compare versions
id: compare_versions
run: |
homebrew_version="${{ steps.get_version.outputs.current_version }}"
latest_tag="${{ steps.fetch_tag.outputs.latest_tag }}"
echo "Homebrew version: $homebrew_version"
echo "Latest tag: $latest_tag"
if [ "$homebrew_version" != "$latest_tag" ]; then
echo "mismatch=true" >> "$GITHUB_OUTPUT"
else
echo "mismatch=false" >> "$GITHUB_OUTPUT"
fi
- name: Fetch checksum for latest release
if: steps.compare_versions.outputs.mismatch == 'true'
id: fetch_checksum
run: |
checksum=$(curl -sL "https://github.com/algorand/go-algorand/releases/download/v${{ steps.fetch_tag.outputs.latest_tag }}-stable/node_stable_darwin-universal_${{ steps.fetch_tag.outputs.latest_tag }}.tar.gz" | shasum -a 256 | awk '{print $1}')
echo "checksum=$checksum" >> "$GITHUB_OUTPUT"
- name: Update algorand.rb
if: steps.compare_versions.outputs.mismatch == 'true'
run: |
sed -i '' "s|url \"https://github.com/algorand/go-algorand/releases/download/v[0-9.]*-stable/node_stable_darwin-universal_[0-9.]*.tar.gz\"|url \"https://github.com/algorand/go-algorand/releases/download/v${{ steps.fetch_tag.outputs.latest_tag }}-stable/node_stable_darwin-universal_${{ steps.fetch_tag.outputs.latest_tag }}.tar.gz\"|" Formula/algorand.rb
sed -i '' "s/sha256 \".*\"/sha256 \"${{ steps.fetch_checksum.outputs.checksum }}\"/" Formula/algorand.rb
- name: Test formula installation
if: steps.compare_versions.outputs.mismatch == 'true'
run: |
brew install --build-from-source ./Formula/algorand.rb --formula 2>&1
brew --prefix algorand --installed
"$(brew --prefix algorand)/bin/algod" -v
brew uninstall algorand
- name: Commit and push changes
if: steps.compare_versions.outputs.mismatch == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/algorand.rb
git commit -m "Update Algorand version to ${{ steps.fetch_tag.outputs.latest_tag }}"
git push