function determineReleaseToDownload(releases, currentVersion) {
    if (releases.length === 0) {
        throw new ValetudoUpdaterError(
            ValetudoUpdaterError.ERROR_TYPE.NO_RELEASE,
            "No release found"
        );
    }

    const releaseVersions = releases.map(r => {
        return r.version;
    });
    const currentVersionIndex = releaseVersions.indexOf(currentVersion);

    if (currentVersionIndex === -1) { //Default to the latest release
        return {
            release: releases[0],
            updateRequired: true
        };
    } else if (currentVersionIndex > 0) { //Always try to pick the next chronological release if possible
        return {
            release: releases[currentVersionIndex-1],
            updateRequired: true
        };
    } else { //We're already on the latest release
        return {
            release: releases[0],
            updateRequired: false
        };
    }
}
@param {Array<import("./update_provider/ValetudoRelease")>} releases
@param {string} currentVersion

@return {{release: import("./update_provider/ValetudoRelease"), updateRequired: boolean}}
@throws {ValetudoUpdaterError}