Skip to content

Commit 03f3c78

Browse files
Merge pull request #1 from pschmitt/latest
Install latest version with 'latest' command line argument
2 parents 9e3b532 + 7719a30 commit 03f3c78

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ For example, install Hack v3.003 with the following command:
2727
$ ./hack-linux-installer.sh v3.003
2828
```
2929

30+
Alternatively, you can use the installer to install the latest version like so:
31+
32+
```
33+
$ ./hack-linux-installer.sh latest
34+
```
35+
3036
#### What it does
3137

3238
- The release archive is pulled from the repository release

hack-linux-installer.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@
1010
# MIT License
1111
#
1212
# Usage: ./hack-linux-installer.sh [VERSION]
13-
# Format the version number as vX.XXX
13+
# Format the version number as vX.XXX or "latest"
1414
#
1515
# /////////////////////////////////////////////////////////////////
1616

1717
HACK_INSTALL_PATH="$HOME/.local/share/fonts"
1818

19+
get_latest_release() {
20+
curl -s "https://api.github.com/repos/source-foundry/Hack/releases/latest" |
21+
grep '"tag_name":' |
22+
sed -E 's/.*"([^"]+)".*/\1/'
23+
}
24+
1925
if [ $# -ne 1 ]; then
20-
echo "Please include a version number argument formatted as vX.XXX"
26+
echo "Please include a version number argument formatted as vX.XXX (or \"latest\")"
2127
exit 1
2228
fi
2329

2430
if [ "$1" = "--help" ]; then
2531
echo "Usage: ./hack-linux-installer [VERSION]"
26-
echo "Format [VERSION] as vX.XXX for the desired release version of the fonts."
32+
echo "Format [VERSION] as vX.XXX for the desired release version of the fonts. Or just set it to \"latest\"."
2733
exit 0
2834
fi
2935

@@ -32,7 +38,11 @@ if [ ! -d "$HACK_INSTALL_PATH" ]; then
3238
exit 1
3339
fi
3440

35-
HACK_VERSION="$1"
41+
HACK_VERSION="${1:-latest}"
42+
if [ "$HACK_VERSION" = "latest" ]
43+
then
44+
HACK_VERSION="$(get_latest_release)"
45+
fi
3646
HACK_DL_URL="https://github.com/source-foundry/Hack/releases/download/$HACK_VERSION/Hack-$HACK_VERSION-ttf.tar.gz"
3747
HACK_ARCHIVE_PATH="Hack-$HACK_VERSION-ttf.tar.gz"
3848

0 commit comments

Comments
 (0)