Skip to content

Commit

Permalink
Add check for latest version (#4194)
Browse files Browse the repository at this point in the history

Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso authored Sep 3, 2023
1 parent 69d317b commit 3e8cd48
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 23 additions & 1 deletion nextflow
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ function get() {
fi
}

function get_ver() {
if command -v curl &>/dev/null; then
curl -fsSL "$1"
elif command -v wget &>/dev/null; then
wget "$1" >/dev/null 2>&1
else
echo_red "ERROR: Cannot find 'curl' nor 'wget' utility -- please install one of them"
exit 1
fi
}

function make_temp() {
local base=${NXF_TEMP:=$PWD}
if [ "$(uname)" = 'Darwin' ]; then mktemp "${base}/nxf-tmp.XXXXXX" || exit $?
Expand All @@ -111,7 +122,7 @@ function resolve_link() {
}

function current_ver() {
[[ $NXF_EDGE == 1 ]] && printf 'edge' || printf 'latest'
[[ $NXF_EDGE == 1 || $NXF_VER == *"-edge" ]] && printf 'edge' || printf 'latest'
}

function install() {
Expand All @@ -131,6 +142,15 @@ function install() {
echo ''
}

function check_latest() {
[[ $cmd != run ]] && return 0
[[ $NXF_OFFLINE == true || $NXF_DISABLE_CHECK_LATEST == true ]] && return 0
local latest=$(get_ver "$NXF_BASE/$(current_ver)/version?current=$NXF_VER")
if [[ -n "$latest" && "$latest" != $NXF_VER ]]; then
echo_yellow "Nextflow $latest is available - Please consider updating your version to it"
fi
}

function launch_nextflow() {
# the launch command line
local cmdline=()
Expand Down Expand Up @@ -445,5 +465,7 @@ else

fi

# check for latest version
check_latest
# finally run it
launch_nextflow
3 changes: 3 additions & 0 deletions packing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ task release(type: Exec, dependsOn: [pack, dockerImage]) {
def launcherSha1 = file('nextflow.sha1').absoluteFile
def launcherSha256 = file('nextflow.sha256').absoluteFile
def nextflowAllFile = file("$releaseDir/nextflow-${version}-all")
def versionFile = file('VERSION').absoluteFile

def snapshot = version ==~ /^.+(-RC\d+|-SNAPSHOT)$/
def edge = version ==~ /^.+(-edge|-EDGE)$/
Expand All @@ -350,6 +351,7 @@ task release(type: Exec, dependsOn: [pack, dockerImage]) {
aws s3 cp $launcherSha1 s3://www2.nextflow.io/releases/edge/nextflow.sha1 $s3CmdOpts
aws s3 cp $launcherSha256 s3://www2.nextflow.io/releases/edge/nextflow.sha256 $s3CmdOpts
aws s3 cp $launcherSha256 s3://www2.nextflow.io/releases/edge/nextflow.md5 $s3CmdOpts
aws s3 cp $versionFile s3://www2.nextflow.io/releases/edge/version $s3CmdOpts
""".stripIndent()

else if( isLatest )
Expand All @@ -361,6 +363,7 @@ task release(type: Exec, dependsOn: [pack, dockerImage]) {
aws s3 cp $launcherSha1 s3://www2.nextflow.io/releases/latest/nextflow.sha1 $s3CmdOpts
aws s3 cp $launcherSha256 s3://www2.nextflow.io/releases/latest/nextflow.sha256 $s3CmdOpts
aws s3 cp $launcherSha256 s3://www2.nextflow.io/releases/latest/nextflow.md5 $s3CmdOpts
aws s3 cp $versionFile s3://www2.nextflow.io/releases/latest/version $s3CmdOpts
""".stripIndent()

def temp = File.createTempFile('upload',null)
Expand Down

0 comments on commit 3e8cd48

Please sign in to comment.