From 7f78ec0a32de88f09bf0234cc5ba99b6b71cad95 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 21 Aug 2023 16:05:59 +0100 Subject: [PATCH] Include PHP binary URLs in GitHub releases and build info --- .github/workflows/discord-release-embed.php | 22 ++++++++++++++++++--- .github/workflows/draft-release.yml | 21 ++++++++++++++++++-- build/generate-build-info-json.php | 7 ++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/workflows/discord-release-embed.php b/.github/workflows/discord-release-embed.php index 9bcb41bc8..5acffdf2e 100644 --- a/.github/workflows/discord-release-embed.php +++ b/.github/workflows/discord-release-embed.php @@ -18,7 +18,12 @@ require dirname(__DIR__, 2) . '/vendor/autoload.php'; /** * @phpstan-return array */ -function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl, string $buildLogUrl, int $newsPingRoleId) : array{ +function generateDiscordEmbed(string $version, string $channel, string $description, string $detailsUrl, string $sourceUrl, string $pharDownloadUrl, string $buildLogUrl, int $newsPingRoleId, ?string $phpDownloadUrl) : array{ + if($phpDownloadUrl !== null){ + $phpEmbedLink = " | [PHP Binaries]($phpDownloadUrl)"; + }else{ + $phpEmbedLink = ""; + } return [ "content" => "<@&$newsPingRoleId> New PocketMine-MP release: $version ($channel)", "embeds" => [ @@ -27,7 +32,7 @@ function generateDiscordEmbed(string $version, string $channel, string $descript "description" => << $detailsUrl, "color" => $channel === "stable" ? 0x57ab5a : 0xc69026 @@ -84,10 +89,21 @@ $detailsUrl = $buildInfoJson["details_url"]; $sourceUrl = $buildInfoJson["source_url"]; $pharDownloadUrl = $buildInfoJson["download_url"]; $buildLogUrl = $buildInfoJson["build_log_url"]; +$phpBinaryUrl = $buildInfoJson["php_download_url"] ?? null; $description = $releaseInfoJson["body"]; -$discordPayload = generateDiscordEmbed($buildInfoJson["base_version"], $buildInfoJson["channel"], $description, $detailsUrl, $sourceUrl, $pharDownloadUrl, $buildLogUrl, (int) $newsPingRoleId); +$discordPayload = generateDiscordEmbed( + $buildInfoJson["base_version"], + $buildInfoJson["channel"], + $description, + $detailsUrl, + $sourceUrl, + $pharDownloadUrl, + $buildLogUrl, + (int) $newsPingRoleId, + $phpBinaryUrl +); $response = Internet::postURL( $hookURL, diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index edb8bae63..aa6fd885d 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -11,6 +11,8 @@ jobs: runs-on: ubuntu-20.04 strategy: fail-fast: false + matrix: + php-version: [8.1] steps: - uses: actions/checkout@v3 @@ -20,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@2.25.2 with: - php-version: 8.1 + php-version: ${{ matrix.php-version }} - name: Restore Composer package cache uses: actions/cache@v3 @@ -58,8 +60,21 @@ jobs: echo CHANGELOG_SUFFIX=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "" : "-" . \pocketmine\VersionInfo::BUILD_CHANNEL;') >> $GITHUB_OUTPUT echo PRERELEASE=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BUILD_CHANNEL === "stable" ? "false" : "true";') >> $GITHUB_OUTPUT + - name: Generate PHP binary download URL + id: php-binary-url + run: | + echo PHP_BINARY_URL="${{ github.server_url }}/${{ github.repository_owner }}/PHP-Binaries/releases/tag/php-${{ matrix.php-version }}-latest" >> $GITHUB_OUTPUT + - name: Generate build info - run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} ${{ steps.build-number.outputs.BUILD_NUMBER }} ${{ github.run_id }} > build_info.json + run: | + php build/generate-build-info-json.php \ + ${{ github.sha }} \ + ${{ steps.get-pm-version.outputs.PM_VERSION }} \ + ${{ github.repository }} \ + ${{ steps.build-number.outputs.BUILD_NUMBER }} \ + ${{ github.run_id }} \ + ${{ steps.php-binary-url.outputs.PHP_BINARY_URL }} \ + > build_info.json - name: Upload release artifacts uses: actions/upload-artifact@v3 @@ -85,4 +100,6 @@ jobs: Please see the [changelogs](${{ github.server_url }}/${{ github.repository }}/blob/${{ steps.get-pm-version.outputs.PM_VERSION }}/changelogs/${{ steps.get-pm-version.outputs.PM_VERSION_SHORT }}${{ steps.get-pm-version.outputs.CHANGELOG_SUFFIX }}.md#${{ steps.get-pm-version.outputs.PM_VERSION_MD }}) for details. + :information_source: Download the recommended PHP binary [here](${{ steps.php-binary-url.outputs.PHP_BINARY_URL }}). + :warning: **4.x is now deprecated. Please read https://github.com/pmmp/PocketMine-MP/issues/5784 for details, and prepare to upgrade to 5.x.** diff --git a/build/generate-build-info-json.php b/build/generate-build-info-json.php index f0ffe7df8..b29d1c728 100644 --- a/build/generate-build-info-json.php +++ b/build/generate-build-info-json.php @@ -23,13 +23,13 @@ declare(strict_types=1); require dirname(__DIR__) . '/vendor/autoload.php'; -if(count($argv) !== 6){ - fwrite(STDERR, "required args: \n"); +if(count($argv) !== 7){ + fwrite(STDERR, "required args: \n"); exit(1); } echo json_encode([ - "php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION), + "php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION), //deprecated "base_version" => \pocketmine\VersionInfo::BASE_VERSION, "build" => (int) $argv[4], "is_dev" => \pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD, @@ -41,4 +41,5 @@ echo json_encode([ "download_url" => "https://github.com/$argv[3]/releases/download/$argv[2]/PocketMine-MP.phar", "source_url" => "https://github.com/$argv[3]/tree/$argv[2]", "build_log_url" => "https://github.com/$argv[3]/actions/runs/$argv[5]", + "php_download_url" => $argv[6], ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR) . "\n";