Skip to content

Instantly share code, notes, and snippets.

@KygekDev
Last active December 2, 2021 07:36
Show Gist options
  • Save KygekDev/03ed5fe1af07ade557770845728e7724 to your computer and use it in GitHub Desktop.
Save KygekDev/03ed5fe1af07ade557770845728e7724 to your computer and use it in GitHub Desktop.

Get the latest PocketMine-MP 4 PHP binary URL from Azure DevOps

Prerequisites

You need PHP installed with HTTPS file_get_contents() feature enabled in php.ini.

Code

Make a new file named azure.php and copy the PHP code below to the file:

<?php

const BUILDS_REST_API = "https://dev.azure.com/pocketmine/PHP-Builds/_apis/build/builds?api-version=6.0&branchName=refs/heads/stable";

if (count($argv) < 2) {
    echo "Operating system argument is required!";
    exit(1);
} elseif (!in_array($argv[1], ["Windows", "Linux", "Mac"])) {
    echo "Unknown operating system!";
    exit(1);
}

$runs = json_decode(file_get_contents(BUILDS_REST_API), true);
$buildId = $runs["value"]["0"]["id"];

echo "https://dev.azure.com/pocketmine/a29511ba-1771-4ad2-a606-23c00a4b8b92/_apis/build/builds/" . $buildId . "/artifacts?artifactName=" . $argv[1] . "&api-version=4.1&%24format=zip";

Running

Run the following commands to get the URL of the latest PocketMine-MP 4 PHP binary (Case sensitive!):

Windows:

$ php azure.php Windows

Linux:

$ php azure.php Linux

Mac OS:

$ php azure.php Mac

It will print the URL in your terminal, or to a file or program if you use shell commands to process the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment