Skip to content

Commit 2e7cc02

Browse files
authored
WorkflowBugfix: Use release tags to filter versions and avoid pagination (#6)
1 parent 4003c4d commit 2e7cc02

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

install-hugo.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ fi
1313
VFILE=".hugoversion"
1414
VERSION=$(cat $VFILE)
1515

16-
echo "Searching for Hugo $VERSION"
17-
18-
URL=`curl -s https://api.github.com/repos/gohugoio/hugo/releases \
19-
| jq -r --arg version $VERSION \
20-
'[.[]
21-
| select(.tag_name == $version)
22-
| .assets[]
23-
| select(.browser_download_url | test("hugo_extended(.*)Linux-64bit"))][0]
24-
| .browser_download_url'`
16+
TAG_URL="https://api.github.com/repos/gohugoio/hugo/releases/tags/$VERSION"
17+
echo "Searching for Hugo $VERSION at $TAG_URL"
18+
19+
URL=$(curl -s "$TAG_URL" |
20+
jq -r '[.assets[] | select(.browser_download_url | test("hugo_extended.*Linux-64bit"))][0] | .browser_download_url')
21+
22+
if [[ -z "$URL" || "$URL" == "null" ]]; then
23+
echo "Could not find a suitable Hugo binary for $VERSION."
24+
exit 1
25+
fi
2526

2627
echo "Found $URL"
2728

0 commit comments

Comments
 (0)