publish_new_release.sh: fix checking/installing dependencies

This commit is contained in:
Benjamin Renard 2024-05-03 15:40:05 +02:00
parent 23adeb0ee2
commit 4f890f6899
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -4,17 +4,37 @@ ROOT_DIR=$( dirname $( realpath $0 ) )
set -e
echo "Checking dependencies..."
MISSING_PACKAGES=()
for bin in /usr/bin/curl /usr/bin/xq /usr/bin/sed /usr/bin/git
do
echo -n "- $bin: "
if [ -x "$bin" ]
then
echo "OK"
else
echo "Missing"
MISSING_PACKAGES+=( $(basename $bin) )
fi
done
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]
then
echo "Install missing packages (${MISSING_PACKAGES[@]})..."
apt install -y ${#MISSING_PACKAGES[@]}
fi
LATEST="$1"
if [ -z "$LATEST" ]
then
echo -n "Getting latest release..."
LATEST=$( curl --silent https://forgejo.org/releases/rss.xml|xq -x '/rss/channel/item[1]/title'|sed 's/^v//' )
LATEST=$( /usr/bin/curl --silent https://forgejo.org/releases/rss.xml|/usr/bin/xq -x '/rss/channel/item[1]/title'|/usr/bin/sed 's/^v//' )
echo done.
fi
echo "Latest release: $LATEST"
[ -n "$( git tag -l "$LATEST" )" ] && echo "Release $LATEST already exists" && exit 1
[ -n "$( /usr/bin/git tag -l "$LATEST" )" ] && echo "Release $LATEST already exists" && exit 1
echo "Press [enter] to create and publish this new release"
read
@ -22,12 +42,12 @@ read
echo "Create new release..."
cd $ROOT_DIR
echo -n "$LATEST" > last_release.txt
git add last_release.txt
git commit -m "Release $LATEST"
git tag "$LATEST"
/usr/bin/git add last_release.txt
/usr/bin/git commit -m "Release $LATEST"
/usr/bin/git tag "$LATEST"
echo done.
echo "Publish new release..."
git push
git push --tags
/usr/bin/git push
/usr/bin/git push --tags
echo done.