Skip to content

Commit 4be07af

Browse files
authored
Query latest release from GitHub (#818)
* add Code::Blocks project folder to .gitignore * Update install.sh script to query latest fpm release from github.com The updated install.sh script queries the latest fpm release version from github directly, instead of having its version hardcoded
1 parent 0cbb0da commit 4be07af

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ build/*
22

33
# Visual Studio Code
44
.vscode/
5+
6+
# CodeBlocks
7+
project/*

install.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ usage()
1818
echo ""
1919
}
2020

21+
# Return value of the latest published release on GitHub, with no heading "v" (e.g., "0.7.0")
22+
get_latest_release()
23+
{
24+
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
25+
grep '"tag_name":' | # Get tag line
26+
sed -E 's/.*"([^"]+)".*/\1/' | # Pluck JSON value
27+
sed -E 's/^v//' # Remove heading "v" if present
28+
}
29+
2130
PREFIX="$HOME/.local"
2231

2332
while [ "$1" != "" ]; do
@@ -42,7 +51,8 @@ done
4251

4352
set -u # error on use of undefined variable
4453

45-
SOURCE_URL="https://github.com/fortran-lang/fpm/releases/download/v0.6.0/fpm-0.6.0.F90"
54+
LATEST_RELEASE=$(get_latest_release "fortran-lang/fpm")
55+
SOURCE_URL="https://github.com/fortran-lang/fpm/releases/download/v${LATEST_RELEASE}/fpm-${LATEST_RELEASE}.F90"
4656
BOOTSTRAP_DIR="build/bootstrap"
4757
if [ -z ${FC+x} ]; then
4858
FC="gfortran"

0 commit comments

Comments
 (0)