~xdavidwu/android-autobuilds

ref: cf9b71a81cca0bd3a518f9672378c54f77792ae0 android-autobuilds/update -rwxr-xr-x 843 bytes
cf9b71a8Pinghao Wu update: move to hut 30 days ago
                                                                                
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
#!/bin/sh

set -e

resolve_branch() {
	res=$(curl --etag-save "$1/etag" --etag-compare "$1/etag" -f "https://api.github.com/repos/$1/git/ref/heads/$2" | jq -r '.object.sha')
	[ -n "$res" ] && echo "$res" && return || true
	[ -n "$3" ] && echo "$3" || (echo "HTTP successful, but no values nor fallback found" >&2; rm "$i/etag"; false)
}

dispatch() {
	repo=$(basename "$1")
	yq ".sources += [\"https://github.com/$1#$2\"] |
		.environment.source = \"$repo\"
	" < build.yml | hut builds submit -n"$1 $2" -t "android-autobuilds/$1" -
}

for i in */*; do
	echo "$i"
	branch=$(cat "$i/branch")
	version=$(cat "$i/version" || true)
	new_ver=$(resolve_branch "$i" "$branch" "$version")
	if [ "$version" != "$new_ver" ]; then
		echo "dispatch $i $new_ver"
		dispatch "$i" "$new_ver" || (rm "$i/etag"; false)
		echo "$new_ver" > "$i/version"
	fi
done