#!/bin/sh
if [ -e ~/.config/sr.ht ]
then
. ~/.config/sr.ht
fi
upstream=https://builds.sr.ht
while getopts u:t:h flag
do
case $flag in
u)
upstream="$OPTARG"
;;
t)
token="$OPTARG"
;;
h)
echo "Usage: $0 [-u https://upstream...] [-t oauth token] <packages...>"
exit 0
;;
esac
done
shift $((OPTIND-1))
builds=""
for target in $*
do
if [ "$builds" = "" ]
then
builds="'$target'"
else
builds="$builds, '$target'"
fi
done
sed "s/packages: \\[\\]/packages: [$builds]/g" < build.yml | jq -sR '{
"manifest": .,
"tags": ["sr.ht-apkbuilds"],
}' | curl \
-H Authorization:"token $oauth_token" \
-H Content-Type:application/json \
-X POST \
-d @- $upstream/api/jobs
printf '\n'