Skip to content

Commit

Permalink
build: do not query GitHub API if origin is upstream
Browse files Browse the repository at this point in the history
If the "origin" remote of the local repository is the upstream repo dtcooper/raspotify, do not query the GitHub API for upstream tags. It is supposed to have tags then, else the local repo is faulty.

Signed-off-by: MichaIng <micha@dietpi.com>
  • Loading branch information
MichaIng committed Jan 16, 2025
1 parent 4687769 commit a934578
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,20 @@ cd /mnt/raspotify
echo 'Obtaining latest Git repository tag for DEB package version ...'
RASPOTIFY_GIT_VER="$(git describe --tags "$(git rev-list --tags --max-count=1)" || :)"
if [ -z "$RASPOTIFY_GIT_VER" ]; then
echo 'Could not obtain latest tag from local repository. Obtaining it from upstream: https://api.github.com/repos/dtcooper/raspotify/tags'
RASPOTIFY_GIT_VER="$(curl -sSf "https://api.github.com/repos/dtcooper/raspotify/tags" | awk -F\" '/^ *"name": "/{print $4;exit}' || :)"
fi
if [ -z "$RASPOTIFY_GIT_VER" ]; then
echo 'Could not obtain latest tag from upstream repository either. Exiting ...'
exit 1
# Derive from origin URL whether this is dtcooper/raspotify and hence supposed to have tags.
# If so, exit right here, else get tags from dtcooper/raspotify via GitHub API, since forks often do not have any tags.
url="$(git remote get-url origin || :)"
if [ "$url" = 'https://github.com/dtcooper/raspotify' ] || [ "$url" = 'https://github.com/dtcooper/raspotify/' ] || [ "$url" = 'https://github.com/dtcooper/raspotify.git' ]; then
echo 'E: Could not obtain any tag. Exiting ...'
exit 1
else
echo 'W: Could not obtain latest tag from local repository. Obtaining it from upstream: https://api.github.com/repos/dtcooper/raspotify/tags'
RASPOTIFY_GIT_VER="$(curl -sSf "https://api.github.com/repos/dtcooper/raspotify/tags" | awk -F\" '/^ *"name": "/{print $4;exit}' || :)"
if [ -z "$RASPOTIFY_GIT_VER" ]; then
echo 'E: Could not obtain latest tag from upstream repository either. Exiting ...'
exit 1
fi
fi
fi
RASPOTIFY_HASH="$(git rev-parse HEAD | cut -c 1-7 || echo unknown)"

Expand Down

0 comments on commit a934578

Please sign in to comment.