-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·27 lines (23 loc) · 811 Bytes
/
update.sh
File metadata and controls
executable file
·27 lines (23 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
latest_version=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/volta-cli/volta/releases?per_page=1 | \
tac | tac | \
grep -m 1 -o '"tag_name": *"[^"]*"' | \
grep -o '"[^"]*"$' | \
tr -d '"' | \
sed 's/^v//')
if [ $? -eq 0 ]; then
# Replace the version in latest.txt
echo "$latest_version" > latest.txt
# Append the latest version to the top of releases.txt if it is different from the last version
if [ "$latest_version" != "$(head -n 1 releases.txt)" ]; then
{ echo "$latest_version"; cat releases.txt; } > temp.txt && mv temp.txt releases.txt
fi
echo "Successfully updated latest.txt and releases.txt."
exit 0
else
echo "Failed to fetch the latest release tag." >&2
exit 1
fi