forgejo-deb/.auto-pr.sh

43 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
# Automatic pull request script
FORGEJO_VERSION_PREFIX="v7.0."
AUTO_PR_BRANCH="main"
cd $(dirname $0)
git fetch
git checkout $AUTO_PR_BRANCH
git reset --hard origin/$AUTO_PR_BRANCH
git submodule update
cd forgejo
git reset --hard
git fetch
FORGEJO_LATEST=$(git tag --sort=committerdate | grep ^$FORGEJO_VERSION_PREFIX | tail -n1)
FORGEJO_CURRENT=$(git describe --tags HEAD)
FORGEJO_NOV=${FORGEJO_LATEST/v/}
CHANGELOG_ADDITION="forgejo ($FORGEJO_NOV-1) unstable; urgency=medium
* Forgejo version $FORGEJO_NOV
* See https://codeberg.org/forgejo/forgejo/src/branch/forgejo/RELEASE-NOTES.md#${FORGEJO_NOV//./-}
-- $(whoami) <$(whoami)@noreply.codeberg.org> $(date --utc "+%a, %d %b %Y %H:%M:%S %z")
"
echo "$CHANGELOG_ADDITION"
cd ..
if [ "$FORGEJO_LATEST" != "$FORGEJO_CURRENT" ];then
if [ "$(git branch | grep autopr-$FORGEJO_LATEST)" ] ; then
echo "Oops! Pr branch already exists, not creating a duplicate pull request..."
exit 99
fi
git branch autopr-$FORGEJO_LATEST
git checkout autopr-$FORGEJO_LATEST
cd forgejo
git checkout "$FORGEJO_LATEST"
cd ..
echo "$CHANGELOG_ADDITION" > deb/debian/changelog-prepend
cat deb/debian/changelog >> deb/debian/changelog-prepend
mv deb/debian/changelog-prepend deb/debian/changelog
git add .
git commit -m "Forgejo $FORGEJO_LATEST"
git push origin HEAD:refs/for/$AUTO_PR_BRANCH/autopr-$FORGEJO_LATEST -o description="_auto-generated pull request_" # -o force-push=true
fi