mirror of
https://github.com/actions/runner-images.git
synced 2025-12-17 15:20:11 +00:00
Fetch latest Julia version from GitHub API
This commit is contained in:
@@ -7,21 +7,33 @@
|
|||||||
# Source the helpers for use with the script
|
# Source the helpers for use with the script
|
||||||
source $HELPER_SCRIPTS/document.sh
|
source $HELPER_SCRIPTS/document.sh
|
||||||
|
|
||||||
|
# This function fetches the latest Julia release from the GitHub API
|
||||||
|
# Based on https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
|
||||||
|
function GetLatestJuliaRelease () {
|
||||||
|
curl --silent "https://api.github.com/repos/julialang/julia/releases/latest" |
|
||||||
|
grep '"tag_name":' |
|
||||||
|
sed -E 's/.*"([^"]+)".*/\1/' |
|
||||||
|
sed 's/v//' # remove v prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# This function installs Julia using the specified arguments:
|
# This function installs Julia using the specified arguments:
|
||||||
# $1=MajorVersion (1.3)
|
# $1=MajorAndMinorVersion (1.3.1)
|
||||||
# $2=MajorAndMinorVersion (1.3.1)
|
# $2=IsDefaultVersion (true or false)
|
||||||
# $3=IsDefaultVersion (true or false)
|
|
||||||
|
|
||||||
function InstallJulia () {
|
function InstallJulia () {
|
||||||
curl -sL "https://julialang-s3.julialang.org/bin/linux/x64/$1/julia-$2-linux-x86_64.tar.gz" -o "julia-$2-linux-x86_64.tar.gz"
|
# Extract Major and Minor version from full version string
|
||||||
mkdir -p "/usr/local/julia$1"
|
juliaMajorAndMinorVersion="$(sed 's/\.*[0-9]//3' <<< $1)"
|
||||||
tar -C "/usr/local/julia$1" -xzf "julia-$2-linux-x86_64.tar.gz" --strip-components=1 julia
|
|
||||||
rm "julia-$2-linux-x86_64.tar.gz"
|
curl -sL "https://julialang-s3.julialang.org/bin/linux/x64/$juliaMajorAndMinorVersion/julia-$1-linux-x86_64.tar.gz" -o "julia-$1-linux-x86_64.tar.gz"
|
||||||
|
mkdir -p "/usr/local/julia$juliaMajorAndMinorVersion"
|
||||||
|
tar -C "/usr/local/julia$juliaMajorAndMinorVersion" -xzf "julia-$1-linux-x86_64.tar.gz" --strip-components=1 julia
|
||||||
|
rm "julia-$1-linux-x86_64.tar.gz"
|
||||||
|
|
||||||
# If this version of Julia is to be the default version,
|
# If this version of Julia is to be the default version,
|
||||||
# symlink it into the path
|
# symlink it into the path
|
||||||
if [ "$3" = true ]; then
|
if [ "$2" = true ]; then
|
||||||
ln -s "/usr/local/julia$1/bin/julia" /usr/bin/julia
|
ln -s "/usr/local/julia$juliaMajorAndMinorVersion/bin/julia" /usr/bin/julia
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run tests to determine that the software installed as expected
|
# Run tests to determine that the software installed as expected
|
||||||
@@ -29,7 +41,7 @@ function InstallJulia () {
|
|||||||
|
|
||||||
# If this version of Julia is to be the default version,
|
# If this version of Julia is to be the default version,
|
||||||
# check that it has been added to PATH
|
# check that it has been added to PATH
|
||||||
if [ "$3" = true ]; then
|
if [ "$2" = true ]; then
|
||||||
if ! command -v julia; then
|
if ! command -v julia; then
|
||||||
echo "Julia was not installed or found on PATH"
|
echo "Julia was not installed or found on PATH"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -37,7 +49,7 @@ function InstallJulia () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify output of julia --version
|
# Verify output of julia --version
|
||||||
if [ ! "$(/usr/local/julia"$1"/bin/julia --version)" = "julia version $2" ]; then
|
if [ ! "$(/usr/local/julia"$juliaMajorAndMinorVersion"/bin/julia --version)" = "julia version $1" ]; then
|
||||||
echo "Julia was not installed correctly"
|
echo "Julia was not installed correctly"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -47,4 +59,4 @@ function InstallJulia () {
|
|||||||
DocumentInstalledItem "Julia ($(julia --version))"
|
DocumentInstalledItem "Julia ($(julia --version))"
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallJulia 1.3 1.3.1 true
|
InstallJulia "$(GetLatestJuliaRelease)" true
|
||||||
|
|||||||
Reference in New Issue
Block a user