-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·58 lines (45 loc) · 1.65 KB
/
update
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
#! /bin/bash
set -e
name=$1
if [ -z "$name" ]; then
echo "Usage: $0 <repo name>"
exit 1
fi
version=$(gh api /repos/avencera/${name}/releases/latest | jq .name -r)
echo "updating $name to $version"
echo ""
echo ""
osx_intel="https://github.com/avencera/${name}/releases/download/${version}/${name}-${version}-x86_64-apple-darwin.tar.gz"
osx_arm="https://github.com/avencera/${name}/releases/download/${version}/${name}-${version}-aarch64-apple-darwin.tar.gz"
linux_intel="https://github.com/avencera/${name}/releases/download/${version}/${name}-${version}-x86_64-unknown-linux-musl.tar.gz"
linux_arm="https://github.com/avencera/${name}/releases/download/${version}/${name}-${version}-aarch64-unknown-linux-musl.tar.gz"
function get_sha() {
curl -L $1 --output file
local sha=$(shasum -a 256 file | awk '{print $1}')
rm file
echo $sha
}
osx_intel_sha=$(get_sha $osx_intel)
osx_arm_sha=$(get_sha $osx_arm)
linux_intel_sha=$(get_sha $linux_intel)
linux_arm_sha=$(get_sha $linux_arm)
echo ""
echo ""
echo "osx intel: $osx_intel_sha"
echo "osx arm: $osx_arm_sha"
echo "linux intel: $linux_intel_sha"
echo "linux arm: $linux_arm_sha"
echo ""
cat pkg/brew/${name}.rb \
| sed "s/version .*/version '${version}'/g" \
| sed '17s/sha256 .*/sha256 "'"$osx_intel_sha"'"/g' \
| sed '22s/sha256 .*/sha256 "'"$osx_arm_sha"'"/g' \
| sed '27s/sha256 .*/sha256 "'"$linux_intel_sha"'"/g' \
| sed '32s/sha256 .*/sha256 "'"$linux_arm_sha"'"/g' \
> pkg/brew/${name}_new.rb
rm pkg/brew/"${name}".rb
mv pkg/brew/"${name}"_new.rb pkg/brew/"${name}".rb
echo "Committing changes"
git cms "Update ${name} to ${version}"
echo "Pushing changes"
git push