Update draft-release.yml #213
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Draft release | |
on: | |
pull_request_target: | |
types: | |
- closed | |
branches: | |
- stable | |
- minor-next | |
- major-next | |
- "legacy/*" | |
paths: | |
- "src/VersionInfo.php" | |
jobs: | |
check-validity: | |
name: Check that this PR merge is a valid release target | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: [8.2] | |
outputs: | |
valid: ${{ steps.validate.outputs.VALID_RELEASE }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/[email protected] | |
with: | |
php-version: ${{ matrix.php-version }} | |
- name: Restore Composer package cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/composer/files | |
~/.cache/composer/vcs | |
key: "composer-v2-cache-${{ hashFiles('./composer.lock') }}" | |
restore-keys: | | |
composer-v2-cache- | |
- name: Install Composer dependencies | |
run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs | |
- name: Check IS_DEVELOPMENT_BUILD flag | |
id: validate | |
run: | | |
echo VALID_RELEASE=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::IS_DEVELOPMENT_BUILD ? "false" : "true";') >> $GITHUB_OUTPUT | |
#TODO: check this user is authorized to create a release PR in the first place | |
draft: | |
name: Create GitHub draft release | |
needs: [check-validity] | |
if: jobs.check-validity.outputs.valid == true | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: [8.2] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup PHP | |
uses: shivammathur/[email protected] | |
with: | |
php-version: ${{ matrix.php-version }} | |
- name: Restore Composer package cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/composer/files | |
~/.cache/composer/vcs | |
key: "composer-v2-cache-${{ hashFiles('./composer.lock') }}" | |
restore-keys: | | |
composer-v2-cache- | |
- name: Install Composer dependencies | |
run: composer install --no-dev --prefer-dist --no-interaction --ignore-platform-reqs | |
- name: Calculate build number | |
id: build-number | |
run: | | |
BUILD_NUMBER=$((2000+$GITHUB_RUN_NUMBER)) #to stay above jenkins | |
echo "Build number: $BUILD_NUMBER" | |
echo BUILD_NUMBER=$BUILD_NUMBER >> $GITHUB_OUTPUT | |
- name: Check IS_DEVELOPMENT_BUILD flag | |
- 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 }} --build ${{ steps.build-number.outputs.BUILD_NUMBER }} | |
- name: Get PocketMine-MP release version | |
id: get-pm-version | |
run: | | |
echo PM_VERSION=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\VersionInfo::BASE_VERSION;') >> $GITHUB_OUTPUT | |
echo MCPE_VERSION=$(php -r 'require "vendor/autoload.php"; echo \pocketmine\network\mcpe\protocol\ProtocolInfo::MINECRAFT_VERSION_NETWORK;') >> $GITHUB_OUTPUT | |
echo PM_VERSION_SHORT=$(php -r 'require "vendor/autoload.php"; $v = explode(".", \pocketmine\VersionInfo::BASE_VERSION); array_pop($v); echo implode(".", $v);') >> $GITHUB_OUTPUT | |
echo PM_VERSION_MD=$(php -r 'require "vendor/autoload.php"; echo str_replace(".", "", \pocketmine\VersionInfo::BASE_VERSION);') >> $GITHUB_OUTPUT | |
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 }} \ | |
${{ steps.php-binary-url.outputs.PHP_BINARY_URL }} \ | |
> build_info.json | |
- name: Generate core permission doc for doc.pmmp.io | |
run: php tools/generate-permission-doc.php rst | |
- name: Upload release artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release_artifacts | |
path: | | |
${{ github.workspace }}/PocketMine-MP.phar | |
${{ github.workspace }}/start.* | |
${{ github.workspace }}/build_info.json | |
${{ github.workspace }}/core-permissions.rst | |
- name: Create draft release | |
uses: ncipollo/[email protected] | |
with: | |
artifacts: ${{ github.workspace }}/PocketMine-MP.phar,${{ github.workspace }}/start.*,${{ github.workspace }}/build_info.json,${{ github.workspace }}/core-permissions.rst | |
commit: ${{ github.sha }} | |
draft: true | |
prerelease: ${{ steps.get-pm-version.outputs.PRERELEASE }} | |
name: PocketMine-MP ${{ steps.get-pm-version.outputs.PM_VERSION }} | |
tag: ${{ steps.get-pm-version.outputs.PM_VERSION }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
**For Minecraft: Bedrock Edition ${{ steps.get-pm-version.outputs.MCPE_VERSION }}** | |
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 }}). |