~xdavidwu/android-autobuilds

9059c6d53f324ddf1f937efd0046db339e87876d — xdavidwu 2 years ago
initial commit
A  => .gitignore +2 -0
@@ 1,2 @@
version
etag

A  => LineageOS/android_packages_apps_Backgrounds/branch +1 -0
@@ 1,1 @@
lineage-16.0

A  => LineageOS/android_packages_apps_Backgrounds/build-tools +1 -0
@@ 1,1 @@
28.0.3

A  => LineageOS/android_packages_apps_Backgrounds/platform +1 -0
@@ 1,1 @@
28

A  => LineageOS/android_packages_apps_Eleven/branch +1 -0
@@ 1,1 @@
lineage-19.1

A  => LineageOS/android_packages_apps_Eleven/build-tools +1 -0
@@ 1,1 @@
30.0.2

A  => LineageOS/android_packages_apps_Eleven/platform +1 -0
@@ 1,1 @@
31

A  => LineageOS/android_packages_apps_Jelly/branch +1 -0
@@ 1,1 @@
lineage-19.1

A  => LineageOS/android_packages_apps_Jelly/build-tools +1 -0
@@ 1,1 @@
30.0.3

A  => LineageOS/android_packages_apps_Jelly/platform +1 -0
@@ 1,1 @@
31

A  => LineageOS/android_packages_apps_Recorder/branch +1 -0
@@ 1,1 @@
lineage-19.1

A  => LineageOS/android_packages_apps_Recorder/build-tools +1 -0
@@ 1,1 @@
30.0.2

A  => LineageOS/android_packages_apps_Recorder/platform +1 -0
@@ 1,1 @@
31

A  => build.yml +35 -0
@@ 1,35 @@
image: archlinux
repositories:
  aurbuild: >
    https://aurbuild.xdavidwu.link/#F73F137D4573DEFAA097DBF09544CFF6B08A3FD3
  # hackish, key seems mandatory
  multilib: >
    https://asia.mirror.pkgbuild.com/multilib/os/x86_64/#F73F137D4573DEFAA097DBF09544CFF6B08A3FD3
packages:
  - jdk11-openjdk
  - android-sdk-cmdline-tools-latest
secrets:
  - a32cf57c-bbf2-4054-b7d1-8ff2bb2baed1
  - a7670f65-3769-4459-8146-bf43a8b0b009
sources:
environment:
tasks:
  - patch: |
      cd "$source"
      sed -i "s/versionCode.*$/versionCode $(date +'%s')/" $(find . -name build.gradle)
  - build: |
      . /etc/profile
      cd "$source"
      ./gradlew assembleDebug
  - deploy: |
      cd "$source"
      ver=$(git rev-parse HEAD)
      test -f build/outputs/apk/debug/*-debug.apk && apk=$(echo build/outputs/apk/debug/*-debug.apk) || true
      test -f */build/outputs/apk/debug/*-debug.apk && apk=$(echo */build/outputs/apk/debug/*-debug.apk) || true
      test -f "$apk"
      echo "StrictHostKeyChecking=no" >> ~/.ssh/config
      ssh deploy@fdroid.xdavidwu.link "$source-debug-$ver.apk" < "$apk"
triggers:
  - action: email
    condition: always
    to: xdavidwuph@gmail.com

A  => update +32 -0
@@ 1,32 @@
#!/bin/sh

set -e

resolve_branch() {
	headers=$(mktemp)
	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\",\"android-sdk-build-tools-$build_tools\"]
	" < build.yml | ssh builds@builds.xdavidwu.link "submit -n$1\ $2"
}

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