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"
|
2021-09-11 11:16:10 +00:00
|
|
|
reprepro --export=silent-never -b ../debian includedeb unstable "$name"
|
2021-09-11 09:37:29 +00:00
|
|
|
done
|
|
|
|
)
|
2021-09-11 09:49:12 +00:00
|
|
|
|
2021-09-11 11:16:10 +00:00
|
|
|
if has_changes debian/pool; then
|
|
|
|
reprepro -b debian export unstable
|
|
|
|
fi
|
|
|
|
|
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
|