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 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" LATEST="$1"
if [ -z "$LATEST" ] if [ -z "$LATEST" ]
then then
echo -n "Getting latest release..." 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. echo done.
fi fi
echo "Latest release: $LATEST" 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" echo "Press [enter] to create and publish this new release"
read read
@ -22,12 +42,12 @@ read
echo "Create new release..." echo "Create new release..."
cd $ROOT_DIR cd $ROOT_DIR
echo -n "$LATEST" > last_release.txt echo -n "$LATEST" > last_release.txt
git add last_release.txt /usr/bin/git add last_release.txt
git commit -m "Release $LATEST" /usr/bin/git commit -m "Release $LATEST"
git tag "$LATEST" /usr/bin/git tag "$LATEST"
echo done. echo done.
echo "Publish new release..." echo "Publish new release..."
git push /usr/bin/git push
git push --tags /usr/bin/git push --tags
echo done. echo done.