#!/usr/bin/env bash
set -euo pipefail
: "${DEPLOY_SOURCE:?Set DEPLOY_SOURCE to the application checkout}"
: "${DEPLOY_PACKAGE:?Set DEPLOY_PACKAGE to an output ZIP path}"
: "${OVH_PHP_VERSION:?Set OVH_PHP_VERSION to the server PHP major.minor version}"
tool_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
[[ "$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')" == "$OVH_PHP_VERSION" ]] || {
    printf 'Build PHP does not match OVH_PHP_VERSION.\n' >&2; exit 1;
}
python3 "$tool_dir/transfer.py" build
