-git tag -u 058D8206 -m "next-$d" "next-$d"
-git update-ref refs/heads/stable refs/remotes/origin/master
+git tag -u $gpg_key -m "$n" "$n"
+
+git branch -f stable refs/remotes/origin/master
+
+p="patch-$l-$n"
+git diff-tree -p "$l.." >"../$p"
+gpg -u $kup_gpg_key -a -b "../$p"
+
+oldest=$(date --date "3 months ago" '+%Y%m%d')
+echo "Removing old releases ... <= next-$oldest"
+
+old_tags=$(git tag -l 'next-*[0-9]' |
+ awk -F - '$2 ~ /^[0-9]*$/ && $2 <= '$oldest' { printf("next-%s\n", $2); }')
+
+[ "$old_tags" ] && git tag -d $old_tags
+
+echo Pushing to korg ...
+git push --prune korg
+
+echo Pushing to korg-history ...
+git push korg-history
+
+echo Pushing to history
+git push history