Compile without macOS & Android for now #1
This file contains hidden or 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: Build PHP binaries | ||
on: | ||
workflow_call: | ||
inputs: | ||
pm-version-major: | ||
description: 'PocketMine-MP major version' | ||
required: true | ||
type: number | ||
php-version-base: | ||
description: 'PHP base version' | ||
required: true | ||
type: string | ||
special-release: | ||
description: 'Special release type to create (pm-default-latest, pm-default, none)' | ||
required: true | ||
type: string | ||
pm-preview: | ||
description: "Mark releases as pre-release" | ||
required: true | ||
type: boolean | ||
env: | ||
MUSL_CROSS_MAKE_VERSION: 43fcb1e63786b96add78f89d7454709ae0159fa0 | ||
jobs: | ||
linux: | ||
name: Linux | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- name: Install tools and dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install make autoconf automake libtool libtool-bin m4 wget libc-bin gzip bzip2 bison g++ git re2c | ||
- name: Prepare compile.sh download cache | ||
id: download-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./download_cache | ||
key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }} | ||
restore-keys: compile-sh-cache-ssl-https- | ||
- name: Compile PHP | ||
run: | | ||
# Used "set -ex" instead of hashbang since script isn't executed with hashbang | ||
set -ex | ||
trap "exit 1" ERR | ||
./compile.sh -t linux64 -j 4 -g -F -P ${{ inputs.pm-version-major }} -c ./download_cache -D -z ${{ inputs.php-version-base }} | ||
- name: Create tarball | ||
run: | | ||
tar -czf ./PHP-${{ inputs.php-version-base }}-Linux-x86_64-PM${{ inputs.pm-version-major }}.tar.gz bin | ||
tar -czf ./Z-PHP-${{ inputs.php-version-base }}-Linux-x86_64-PM${{ inputs.pm-version-major }}-debugging-symbols.tar.gz bin-debug | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: PHP-${{ inputs.php-version-base }}-Linux-PM${{ inputs.pm-version-major }} | ||
path: | | ||
./*PHP-${{ inputs.php-version-base }}-Linux-x86_64-PM${{ inputs.pm-version-major }}*.tar.gz | ||
install.log | ||
compile.sh | ||
if-no-files-found: error | ||
- name: Prepare workspace for upload | ||
if: failure() | ||
run: tar -czf workspace.tar.gz install_data | ||
- name: Upload workspace | ||
uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: PHP-${{ inputs.php-version-base }}-Linux-workspace-PM${{ inputs.pm-version-major }} | ||
path: | | ||
workspace.tar.gz | ||
if-no-files-found: error | ||
windows: | ||
name: Windows | ||
runs-on: windows-2022 | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- name: Prepare download cache | ||
id: download-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./download_cache | ||
key: windows-cache-${{ hashFiles('./windows-compile-vs.ps1') }} | ||
restore-keys: windows-cache- | ||
- name: Compile PHP | ||
run: .\windows-compile-vs.ps1 | ||
env: | ||
SOURCES_PATH: ${{ github.workspace }}\pocketmine-php-sdk | ||
PM_VERSION_MAJOR: ${{ inputs.pm-version-major }} | ||
PHP_VERSION_BASE: ${{ inputs.php-version-base }} | ||
- name: Prepare artifacts | ||
run: | | ||
mkdir temp | ||
Compress-Archive -Path .\bin -DestinationPath "PHP-${{ inputs.php-version-base }}-Windows-x64-PM${{ inputs.pm-version-major }}.zip" | ||
move php-debug-pack-*.zip temp/Z-PHP-${{ inputs.php-version-base }}-Windows-x64-PM${{ inputs.pm-version-major }}-debugging-symbols.zip | ||
move temp\*.zip . | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: PHP-${{ inputs.php-version-base }}-Windows-PM${{ inputs.pm-version-major }} | ||
path: | | ||
*PHP-${{ inputs.php-version-base }}-Windows-x64-PM${{ inputs.pm-version-major }}*.zip | ||
compile.log | ||
windows-compile-vs.bat | ||
if-no-files-found: error | ||
publish: | ||
name: Publish binaries | ||
needs: [linux, macos, windows] | ||
runs-on: ubuntu-22.04 | ||
if: ${{ github.ref_name == 'stable' && github.ref_type == 'branch' && !contains(github.event.head_commit.message, '[no release]') }} | ||
concurrency: release-${{ inputs.php-version-base }}-pm${{ inputs.pm-version-major }} | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- name: Update latest tag target | ||
run: | | ||
git tag -f pm${{ inputs.pm-version-major }}-php-${{ inputs.php-version-base }}-latest | ||
git push -f origin pm${{ inputs.pm-version-major }}-php-${{ inputs.php-version-base }}-latest | ||
git tag -f pm${{ inputs.pm-version-major }}-latest | ||
git push -f origin pm${{ inputs.pm-version-major }}-latest | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v5 | ||
with: | ||
path: ${{ github.workspace }} | ||
pattern: "*PHP-${{ inputs.php-version-base }}-*-PM${{ inputs.pm-version-major }}" | ||
- name: Download .gdbinit for this PHP version | ||
run: | | ||
curl -L https://raw.githubusercontent.com/php/php-src/refs/heads/PHP-${{ inputs.php-version-base }}/.gdbinit -o Z-PHP-${{ inputs.php-version-base }}.gdbinit | ||
- name: Upload .gdbinit artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: PHP-${{ inputs.php-version-base }}.gdbinit | ||
path: | | ||
${{ github.workspace }}/*.gdbinit | ||
- name: Generate release notes | ||
run: | | ||
echo "### PHP ${{ inputs.php-version-base }} for PocketMine-MP ${{ inputs.pm-version-major }}.x" > changelog.md | ||
echo "Last updated on **$(date -u +'%d %b %Y at %H:%M:%S %Z')**" >> changelog.md | ||
echo -e "\n\n" >> changelog.md | ||
echo "Built by: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> changelog.md | ||
echo "Build number: ${{ github.run_number }}" >> changelog.md | ||
echo -e "\n\n\n" >> changelog.md | ||
echo ":information_source: **Linux/MacOS users**: Please see [this page](https://doc.pmmp.io/en/rtfd/faq/installation/opcache.so.html) to fix extension loading errors. Also, check out the [PocketMine-MP Linux/MacOS installer](https://doc.pmmp.io/en/rtfd/installation/get-dot-pmmp-dot-io.html)." >> changelog.md | ||
echo ":warning: **Windows users**: Don't forget to install [Visual C++ Redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe) or the binary will not work!" >> changelog.md | ||
echo -e "\n\n\n" >> changelog.md | ||
if [[ "${{ inputs.special-release }}" != "none" ]]; then | ||
echo ":white_check_mark: At the time of publication, this version is recommended for PocketMine-MP ${{ inputs.pm-version-major }}.x production servers." >> changelog.md | ||
else | ||
echo ":warning: WARNING! :warning:" >> changelog.md | ||
echo "At the time of publication, plugins for PocketMine-MP ${{ inputs.pm-version-major }}.x may not work this PHP version." >> changelog.md | ||
echo "If you have problems, try the [recommended PM${{ inputs.pm-version-major }} release](${{ github.server_url }}/${{ github.repository }}/releases/pm${{ inputs.pm-version-major }}-latest) instead." >> changelog.md | ||
fi | ||
- name: Get date | ||
id: date | ||
run: | | ||
echo DATE=$(date -u +'%d %b %Y') >> $GITHUB_OUTPUT | ||
- name: Update recommended PM release | ||
uses: ncipollo/[email protected] | ||
if: ${{ inputs.special-release != 'none' }} | ||
with: | ||
artifacts: | | ||
${{ github.workspace }}/*PHP-*-PM*/*.tar.gz | ||
${{ github.workspace }}/*PHP-*-Windows-PM*/*.zip | ||
${{ github.workspace }}/*.gdbinit | ||
name: PM ${{ inputs.pm-version-major }}.x (${{ steps.date.outputs.DATE }}) - Recommended | ||
tag: pm${{ inputs.pm-version-major }}-latest | ||
commit: ${{ github.sha }} | ||
allowUpdates: true | ||
removeArtifacts: true | ||
bodyFile: ${{ github.workspace }}/changelog.md | ||
makeLatest: ${{ inputs.special-release == 'default-latest' }} | ||
prerelease: ${{ inputs.pm-preview == 'true' }} | ||
- name: Update php-version PM release | ||
uses: ncipollo/[email protected] | ||
with: | ||
artifacts: | | ||
${{ github.workspace }}/*PHP-*-PM*/*.tar.gz | ||
${{ github.workspace }}/*PHP-*-Windows-PM*/*.zip | ||
${{ github.workspace }}/*.gdbinit | ||
name: PM ${{ inputs.pm-version-major }}.x (${{ steps.date.outputs.DATE }}) - PHP ${{ inputs.php-version-base }} | ||
tag: pm${{ inputs.pm-version-major }}-php-${{ inputs.php-version-base }}-latest | ||
commit: ${{ github.sha }} | ||
allowUpdates: true | ||
removeArtifacts: true | ||
bodyFile: ${{ github.workspace }}/changelog.md | ||
makeLatest: false | ||
prerelease: ${{ inputs.pm-preview == 'true' }} | ||