-
Notifications
You must be signed in to change notification settings - Fork 1
/
update-formula.sh
executable file
·46 lines (36 loc) · 1.97 KB
/
update-formula.sh
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
#!/bin/bash
TAG_NAME=$1
echo "Setting up variables..."
BASE_URL="https://tailcall.gateway.scarf.sh/${TAG_NAME}"
URL_X86_64="${BASE_URL}/tailcall-x86_64-apple-darwin"
URL_AARCH64="${BASE_URL}/tailcall-aarch64-apple-darwin"
SHA256_X86_64="$(curl -L -s ${URL_X86_64} | sha256sum | cut -d ' ' -f 1)"
SHA256_AARCH64="$(curl -L -s ${URL_AARCH64} | sha256sum | cut -d ' ' -f 1)"
echo "URL (x86_64): ${URL_X86_64}"
echo "SHA256 (x86_64): ${SHA256_X86_64}"
echo "URL (aarch64): ${URL_AARCH64}"
echo "SHA256 (aarch64): ${SHA256_AARCH64}"
echo "Current directory: $(pwd)"
echo "Navigating to the Formula directory..."
cd Formula || exit
echo "Updating URLs and SHA256s in tailcall.rb..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS uses a different syntax for 'sed -i'
sed -i '' -e "/if Hardware::CPU.intel?/,/elsif Hardware::CPU.arm?/ s|url \".*\"|url \"${URL_X86_64}\"|" tailcall.rb
sed -i '' -e "/if Hardware::CPU.intel?/,/elsif Hardware::CPU.arm?/ s|sha256 \".*\"|sha256 \"${SHA256_X86_64}\"|" tailcall.rb
sed -i '' -e "/elsif Hardware::CPU.arm?/,/end/ s|url \".*\"|url \"${URL_AARCH64}\"|" tailcall.rb
sed -i '' -e "/elsif Hardware::CPU.arm?/,/end/ s|sha256 \".*\"|sha256 \"${SHA256_AARCH64}\"|" tailcall.rb
sed -i '' -e "s|version \".*\"|version \"${TAG_NAME}\"|" tailcall.rb
else
# For Linux
sed -i "/if Hardware::CPU.intel?/,/elsif Hardware::CPU.arm?/ s|url \".*\"|url \"${URL_X86_64}\"|" tailcall.rb
sed -i "/if Hardware::CPU.intel?/,/elsif Hardware::CPU.arm?/ s|sha256 \".*\"|sha256 \"${SHA256_X86_64}\"|" tailcall.rb
sed -i "/elsif Hardware::CPU.arm?/,/end/ s|url \".*\"|url \"${URL_AARCH64}\"|" tailcall.rb
sed -i "/elsif Hardware::CPU.arm?/,/end/ s|sha256 \".*\"|sha256 \"${SHA256_AARCH64}\"|" tailcall.rb
sed -i "s|version \".*\"|version \"${TAG_NAME}\"|" tailcall.rb
fi
echo "Script execution complete."
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git commit -am "update tailcall cli version: ${TAG_NAME}"
git push