2021-09-11 09:37:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Downloads upstream releases and uses reprepro to update the
|
|
|
|
# repository in debian/. This is idempotent and doesn't clobber files
|
|
|
|
# if the latest releases is already included.
|
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
release_repo=tonarino/innernet
|
|
|
|
|
|
|
|
has_changes() {
|
2021-09-11 09:43:32 +00:00
|
|
|
git status --porcelain "$@" | grep -q .
|
2021-09-11 09:37:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
local tmpd
|
|
|
|
tmpd="$(mktemp -d tmp.addlatest.XXXXXXXXXX)"
|
|
|
|
|
|
|
|
(
|
|
|
|
cd "$tmpd"
|
|
|
|
|
|
|
|
wget -Olatest.json \
|
|
|
|
-H'Accept: application/json' \
|
|
|
|
"https://api.github.com/repos/$release_repo/releases/latest"
|
|
|
|
|
|
|
|
cat latest.json \
|
|
|
|
| jq -r '.assets[] | select(.name | endswith(".deb")) | (.name + " " + .url)' \
|
|
|
|
| while read name url; do
|
|
|
|
wget --header='Accept: application/octet-stream' -O"$name" "$url"
|
|
|
|
reprepro -b ../debian includedeb unstable "$name"
|
|
|
|
done
|
|
|
|
)
|
2021-09-11 09:49:12 +00:00
|
|
|
|
|
|
|
if has_changes debian/{db,dists,pool}; then
|
|
|
|
git add debian/{db,dists,pool}
|
|
|
|
git \
|
|
|
|
-c 'user.email=41898282+github-actions[bot]@users.noreply.github.com' \
|
|
|
|
-c 'user.name=github-actions[bot]' \
|
|
|
|
commit -m "Included release $release_repo@$(cat "$tmpd/latest.json" | jq -r '.name | ltrimstr("v")')."
|
|
|
|
else
|
|
|
|
echo 'No updates to commit.'
|
|
|
|
fi
|
2021-09-11 09:37:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|