summarylogtreecommitdiffstats
path: root/update
blob: b631824adc2545ac224d50b9e5be75033c98cbb6 (plain)
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
#!/usr/bin/env bash

set -euo pipefail

function fetch() {
	curl -sL "$1"
}

releaseAssets="$(fetch https://api.github.com/repos/evilmartians/lefthook/releases/latest)"

version="$(echo $releaseAssets | jq -r '.name' | sed 's/v//g')"
checksumsUrl="$(echo $releaseAssets | jq -r '.assets[] | select(.name=="lefthook_checksums.txt") | .browser_download_url')"

checksums="$(fetch $checksumsUrl)"

aarch64Checksum="$(echo "$checksums" | grep '_Linux_arm64.gz' | cut -d ' ' -f 1)"
x86_64Checksum="$(echo "$checksums" | grep '_Linux_x86_64.gz' | cut -d ' ' -f 1)"

# Replace version number in PKGBUILD
sed -i "s/pkgver=.*/pkgver=$version/" PKGBUILD

# Replace checksums in PKGBUILD
sed -i "s/sha256sums_aarch64=.*/sha256sums_aarch64=('$aarch64Checksum')/" PKGBUILD
sed -i "s/sha256sums_x86_64=.*/sha256sums_x86_64=('$x86_64Checksum')/" PKGBUILD

makepkg --printsrcinfo >.SRCINFO