~xdavidwu/android-autobuilds

ref: c6375c9a78961b7f0fd6272901c3743f8aa0f21d android-autobuilds/update -rwxr-xr-x 864 bytes
c6375c9aPinghao Wu download sdk from gradle a month 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 | ssh builds@builds.xdavidwu.link "submit -n$1\ $2 -t android-autobuilds -t $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