Yes, that looks good. However, I think we also need to check whether a PR has already been sent with a call to cask-repair
. Otherwise it will continue to create PRs until the first is accepted. What about keeping a local copy with info about the last repair?
# Get revision associated with the last requested update
revision_path="/tmp/slicer-version.txt"
last_requested_revision=`cat $revision_path`
[[ -z $last_requested_revision ]] && echo "Failed to extract revision from $revision_path" && exit 1
# Get revision associated with the last macosx package
package_info=$(curl --progress-bar "http://download.slicer.org/find?os=macosx&stability=any")
version=$(echo $package_info | python -c 'import sys, json; print(json.load(sys.stdin)["version"])') && \
revision=$(echo $package_info | python -c 'import sys, json; print(json.load(sys.stdin)["revision"])') && \
bitstream_id=$(echo $package_info | python -c 'import sys, json; print(json.load(sys.stdin)["download_url"])' | cut -d"/" -f3)
[[ -z $revision ]] && echo "Failed to extract revision from Slicer package info" && exit 1
# If both revision match, we are all set
if [[ $last_requested_revision == $revision ]]; then
exit 0
fi
cask-repair --cask-version $version.$revision,$bitstream_id --fail-on-error --blind-submit slicer-nightly
echo $revision > $revision_path
P.S.: sometimes the bitstream ID changes and not the revision number. Why is that?