diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 6c3caf748..a2718e414 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -35,17 +35,18 @@ jobs: - name: Install Composer dependencies run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs - - name: Patch VersionInfo + - name: Calculate build number + id: build-number run: | BUILD_NUMBER=2000+$GITHUB_RUN_NUMBER #to stay above jenkins echo "Build number: $BUILD_NUMBER" - sed -i "s/const BUILD_NUMBER = 0/const BUILD_NUMBER = ${BUILD_NUMBER}/" src/VersionInfo.php + echo ::set-output name=BUILD_NUMBER::$BUILD_NUMBER - name: Minify BedrockData JSON files run: php vendor/pocketmine/bedrock-data/.minify_json.php - name: Build PocketMine-MP.phar - run: php -dphar.readonly=0 build/server-phar.php --git ${{ github.sha }} + run: php -dphar.readonly=0 build/server-phar.php --git ${{ github.sha }} --build ${{ steps.build-number.outputs.BUILD_NUMBER }} - name: Get PocketMine-MP release version id: get-pm-version @@ -56,7 +57,7 @@ jobs: echo ::set-output name=PM_VERSION_MD::$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\VersionInfo::BASE_VERSION);') - name: Generate build info - run: php build/generate-build-info-json.php ${{ github.sha }} ${{ steps.get-pm-version.outputs.PM_VERSION }} ${{ github.repository }} > 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 }} > build_info.json - name: Upload release artifacts uses: actions/upload-artifact@v2 diff --git a/build/generate-build-info-json.php b/build/generate-build-info-json.php index 6428ce239..00ca2adc8 100644 --- a/build/generate-build-info-json.php +++ b/build/generate-build-info-json.php @@ -23,15 +23,15 @@ declare(strict_types=1); require dirname(__DIR__) . '/vendor/autoload.php'; -if(count($argv) !== 4){ - fwrite(STDERR, "required args: "); +if(count($argv) !== 5){ + fwrite(STDERR, "required args: "); exit(1); } echo json_encode([ "php_version" => sprintf("%d.%d", PHP_MAJOR_VERSION, PHP_MINOR_VERSION), "base_version" => \pocketmine\VersionInfo::BASE_VERSION, - "build" => \pocketmine\VersionInfo::BUILD_NUMBER, + "build" => (int) $argv[4], "is_dev" => \pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD, "channel" => \pocketmine\VersionInfo::BUILD_CHANNEL, "git_commit" => $argv[1], diff --git a/build/server-phar.php b/build/server-phar.php index cb3bc0888..2f5aa1050 100644 --- a/build/server-phar.php +++ b/build/server-phar.php @@ -134,13 +134,18 @@ function main() : void{ exit(1); } - $opts = getopt("", ["out:", "git:"]); + $opts = getopt("", ["out:", "git:", "build:"]); if(isset($opts["git"])){ $gitHash = $opts["git"]; }else{ $gitHash = Git::getRepositoryStatePretty(dirname(__DIR__)); echo "Git hash detected as $gitHash" . PHP_EOL; } + if(isset($opts["build"])){ + $build = (int) $opts["build"]; + }else{ + $build = 0; + } foreach(buildPhar( $opts["out"] ?? getcwd() . DIRECTORY_SEPARATOR . "PocketMine-MP.phar", dirname(__DIR__) . DIRECTORY_SEPARATOR, @@ -150,7 +155,8 @@ function main() : void{ 'vendor' ], [ - 'git' => $gitHash + 'git' => $gitHash, + 'build' => $build ], <<<'STUB' getMetadata(); + if(is_array($meta) && isset($meta["build"]) && is_int($meta["build"])){ + self::$buildNumber = $meta["build"]; + } + } + } + + return self::$buildNumber; + } + /** @var VersionString|null */ private static $fullVersion = null; public static function VERSION() : VersionString{ if(self::$fullVersion === null){ - self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER); + self::$fullVersion = new VersionString(self::BASE_VERSION, self::IS_DEVELOPMENT_BUILD, self::BUILD_NUMBER()); } return self::$fullVersion; } diff --git a/src/crash/CrashDump.php b/src/crash/CrashDump.php index 8407e70ce..f5a3213f1 100644 --- a/src/crash/CrashDump.php +++ b/src/crash/CrashDump.php @@ -279,7 +279,7 @@ class CrashDump{ $this->data->general = new CrashDumpDataGeneral( name: $this->server->getName(), base_version: VersionInfo::BASE_VERSION, - build: VersionInfo::BUILD_NUMBER, + build: VersionInfo::BUILD_NUMBER(), is_dev: VersionInfo::IS_DEVELOPMENT_BUILD, protocol: ProtocolInfo::CURRENT_PROTOCOL, git: VersionInfo::GIT_HASH(),