Skip to content

Commit 8144fb3

Browse files
authored
change tag_name grep to avoid multiple matches
Refactor install.sh to store API response in OUTPUT variable.
1 parent a610134 commit 8144fb3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

release_files/install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ get_release() {
4040
local TAG="tags/${RELEASE}"
4141
local URL="https://api.github.com/repos/${OWNER}/${REPO}/releases/${TAG}"
4242
fi
43+
OUTPUT=""
4344
if [ -n "$GITHUB_TOKEN" ]; then
44-
TAG_NAME=$(curl -H "Authorization: token ${GITHUB_TOKEN}" -s "${URL}" | grep '"tag_name":')
45+
OUTPUT=$(curl -H "Authorization: token ${GITHUB_TOKEN}" -s "${URL}")
4546
else
46-
TAG_NAME=$(curl -s "${URL}" | grep '"tag_name":')
47+
OUTPUT=$(curl -s "${URL}")
4748
fi
49+
TAG_NAME=$(echo ${OUTPUT} | grep -Eo '\"tag_name\":\s*\"v([0-9]+\.){2}[0-9]+"' | tail -n 1)
4850
echo "${TAG_NAME}" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+'
4951
}
5052

0 commit comments

Comments
 (0)