~xdavidwu/android-autobuilds

ref: 7bfc6e1f061aec145d5f94a9478da4920a221fc0 android-autobuilds/update -rwxr-xr-x 1.0 KiB
7bfc6e1fPinghao Wu LineageOS: update to lineage-21.0 1 year, 1 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
29
30
31
#!/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() {
	platform=$(cat "$i/platform")
	build_tools=$(cat "$i/build-tools")
	repo=$(basename "$1")
	yq ".sources += [\"https://github.com/$1#$2\"] |
		.environment.source = \"$repo\" |
		.packages += [\"android-platform${platform:+-$platform}\",\"android-sdk-build-tools${build_tools:+-$build_tools}\"]
	" < 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