Skip to content

Commit 29215d3

Browse files
committed
Restructure Actions workflows
this reduces duplicated information, and in theory also makes sure the publish build waits for everything without needing to be manually listed one by one.
1 parent e15dbcc commit 29215d3

File tree

2 files changed

+172
-158
lines changed

2 files changed

+172
-158
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Build PHP binaries
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
pm-version-major:
7+
description: 'PocketMine-MP major version'
8+
required: true
9+
type: number
10+
11+
jobs:
12+
linux:
13+
name: Linux
14+
runs-on: ubuntu-20.04
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install tools and dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install make autoconf automake libtool libtool-bin m4 wget libc-bin gzip bzip2 bison g++ git re2c
23+
24+
- name: Prepare compile.sh download cache
25+
id: download-cache
26+
uses: actions/cache@v4
27+
with:
28+
path: ./download_cache
29+
key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }}
30+
restore-keys: compile-sh-cache-ssl-https-
31+
32+
- name: Compile PHP
33+
run: |
34+
# Used "set -ex" instead of hashbang since script isn't executed with hashbang
35+
set -ex
36+
trap "exit 1" ERR
37+
./compile.sh -t linux64 -j 4 -g -P ${{ inputs.pm-version-major }} -c ./download_cache -D
38+
39+
- name: Create tarball
40+
run: |
41+
tar -czf ./PHP-Linux-x86_64-PM${{ inputs.pm-version-major }}.tar.gz bin
42+
tar -czf ./PHP-Linux-x86_64-PM${{ inputs.pm-version-major }}-debugging-symbols.tar.gz bin-debug
43+
44+
- name: Upload artifacts
45+
uses: actions/upload-artifact@v4
46+
if: always()
47+
with:
48+
name: Linux-PM${{ inputs.pm-version-major }}
49+
path: |
50+
./PHP-Linux-x86_64-PM${{ inputs.pm-version-major }}*.tar.gz
51+
install.log
52+
compile.sh
53+
if-no-files-found: error
54+
55+
- name: Prepare workspace for upload
56+
if: failure()
57+
run: tar -czf workspace.tar.gz install_data
58+
59+
- name: Upload workspace
60+
uses: actions/upload-artifact@v4
61+
if: failure()
62+
with:
63+
name: Linux-workspace-PM${{ inputs.pm-version-major }}
64+
path: |
65+
workspace.tar.gz
66+
if-no-files-found: error
67+
68+
macos:
69+
name: MacOS ${{ matrix.artifact-name }}
70+
runs-on: ${{ matrix.image }}
71+
strategy:
72+
matrix:
73+
include:
74+
- target-name: mac-x86-64
75+
artifact-name: x86_64
76+
image: macos-12
77+
- target-name: mac-arm64
78+
artifact-name: arm64
79+
image: macos-14
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: Install tools and dependencies
85+
run: brew install libtool autoconf automake pkg-config bison re2c
86+
87+
- name: Prepare compile.sh download cache
88+
id: download-cache
89+
uses: actions/cache@v4
90+
with:
91+
path: ./download_cache
92+
key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }}
93+
restore-keys: compile-sh-cache-ssl-https-
94+
95+
- name: Compile PHP
96+
run: |
97+
export PATH="/usr/local/opt/bison/bin:$PATH"
98+
set -ex
99+
trap "exit 1" ERR
100+
./compile.sh -t ${{ matrix.target-name }} -j4 -g -P ${{ inputs.pm-version-major }} -c ./download_cache -D
101+
102+
- name: Create tarball
103+
run: |
104+
tar -czf ./PHP-MacOS-${{ matrix.artifact-name }}-PM${{ inputs.pm-version-major }}.tar.gz bin
105+
tar -czf ./PHP-MacOS-${{ matrix.artifact-name }}-PM${{ inputs.pm-version-major }}-debugging-symbols.tar.gz bin-debug
106+
107+
- name: Upload artifacts
108+
uses: actions/upload-artifact@v4
109+
if: always()
110+
with:
111+
name: MacOS-${{ matrix.artifact-name }}-PM${{ inputs.pm-version-major }}
112+
path: |
113+
./PHP-MacOS-${{ matrix.artifact-name}}-PM${{ inputs.pm-version-major }}*.tar.gz
114+
install.log
115+
compile.sh
116+
if-no-files-found: error
117+
118+
- name: Prepare workspace for upload
119+
if: failure()
120+
run: tar -czf workspace.tar.gz install_data
121+
122+
- name: Upload workspace
123+
uses: actions/upload-artifact@v4
124+
if: failure()
125+
with:
126+
name: MacOS-${{ matrix.artifact-name }}-workspace-PM${{ inputs.pm-version-major }}
127+
path: |
128+
workspace.tar.gz
129+
if-no-files-found: error
130+
131+
windows:
132+
name: Windows
133+
runs-on: windows-2019
134+
135+
steps:
136+
- uses: actions/checkout@v4
137+
138+
- name: Install tools and dependencies
139+
run: choco install wget --no-progress
140+
141+
- name: Compile PHP
142+
run: .\windows-compile-vs.bat
143+
env:
144+
VS_EDITION: Enterprise
145+
SOURCES_PATH: ${{ github.workspace }}\pocketmine-php-sdk
146+
PM_VERSION_MAJOR: ${{ inputs.pm-version-major }}
147+
148+
- name: Rename artifacts
149+
run: |
150+
mkdir temp
151+
move php-debug-pack-*.zip temp/PHP-Windows-x64-PM${{ inputs.pm-version-major }}-debugging-symbols.zip
152+
move php-*.zip temp/PHP-Windows-x64-PM${{ inputs.pm-version-major }}.zip
153+
move temp\*.zip .
154+
155+
- name: Upload artifacts
156+
uses: actions/upload-artifact@v4
157+
if: always()
158+
with:
159+
name: Windows-PM${{ inputs.pm-version-major }}
160+
path: |
161+
PHP-Windows-x64*.zip
162+
compile.log
163+
windows-compile-vs.bat
164+
if-no-files-found: error

.github/workflows/main.yml

Lines changed: 8 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build PHP binaries
1+
name: Build and publish PHP binaries
22

33
on:
44
push:
@@ -12,171 +12,21 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
linux:
16-
name: Linux (PM ${{ matrix.pm-version-major }})
15+
all-builds:
16+
name: PM${{ matrix.pm-version-major }}
1717
runs-on: ubuntu-20.04
1818
strategy:
1919
matrix:
2020
pm-version-major: [4, 5]
2121

22-
steps:
23-
- uses: actions/checkout@v4
24-
25-
- name: Install tools and dependencies
26-
run: |
27-
sudo apt-get update
28-
sudo apt-get install make autoconf automake libtool libtool-bin m4 wget libc-bin gzip bzip2 bison g++ git re2c
29-
30-
- name: Prepare compile.sh download cache
31-
id: download-cache
32-
uses: actions/cache@v4
33-
with:
34-
path: ./download_cache
35-
key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }}
36-
restore-keys: compile-sh-cache-ssl-https-
37-
38-
- name: Compile PHP
39-
run: |
40-
# Used "set -ex" instead of hashbang since script isn't executed with hashbang
41-
set -ex
42-
trap "exit 1" ERR
43-
./compile.sh -t linux64 -j 4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache -D
44-
45-
- name: Create tarball
46-
run: |
47-
tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin
48-
tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}-debugging-symbols.tar.gz bin-debug
49-
50-
- name: Upload artifacts
51-
uses: actions/upload-artifact@v4
52-
if: always()
53-
with:
54-
name: Linux-PM${{ matrix.pm-version-major }}
55-
path: |
56-
./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}*.tar.gz
57-
install.log
58-
compile.sh
59-
if-no-files-found: error
60-
61-
- name: Prepare workspace for upload
62-
if: failure()
63-
run: tar -czf workspace.tar.gz install_data
64-
65-
- name: Upload workspace
66-
uses: actions/upload-artifact@v4
67-
if: failure()
68-
with:
69-
name: Linux-workspace-PM${{ matrix.pm-version-major }}
70-
path: |
71-
workspace.tar.gz
72-
if-no-files-found: error
73-
74-
macos:
75-
name: MacOS ${{ matrix.artifact-name }} (PM ${{ matrix.pm-version-major }})
76-
runs-on: ${{ matrix.image }}
77-
strategy:
78-
matrix:
79-
pm-version-major: [ 4, 5 ]
80-
artifact-name: [x86_64, arm64]
81-
include:
82-
- target-name: mac-x86-64
83-
artifact-name: x86_64
84-
image: macos-12
85-
- target-name: mac-arm64
86-
artifact-name: arm64
87-
image: macos-14
88-
89-
steps:
90-
- uses: actions/checkout@v4
91-
92-
- name: Install tools and dependencies
93-
run: brew install libtool autoconf automake pkg-config bison re2c
94-
95-
- name: Prepare compile.sh download cache
96-
id: download-cache
97-
uses: actions/cache@v4
98-
with:
99-
path: ./download_cache
100-
key: compile-sh-cache-ssl-https-${{ hashFiles('./compile.sh') }}
101-
restore-keys: compile-sh-cache-ssl-https-
102-
103-
- name: Compile PHP
104-
run: |
105-
export PATH="/usr/local/opt/bison/bin:$PATH"
106-
set -ex
107-
trap "exit 1" ERR
108-
./compile.sh -t ${{ matrix.target-name }} -j4 -g -P ${{ matrix.pm-version-major }} -c ./download_cache -D
109-
110-
- name: Create tarball
111-
run: |
112-
tar -czf ./PHP-MacOS-${{ matrix.artifact-name }}-PM${{ matrix.pm-version-major }}.tar.gz bin
113-
tar -czf ./PHP-MacOS-${{ matrix.artifact-name }}-PM${{ matrix.pm-version-major }}-debugging-symbols.tar.gz bin-debug
114-
115-
- name: Upload artifacts
116-
uses: actions/upload-artifact@v4
117-
if: always()
118-
with:
119-
name: MacOS-${{ matrix.artifact-name }}-PM${{ matrix.pm-version-major }}
120-
path: |
121-
./PHP-MacOS-${{ matrix.artifact-name}}-PM${{ matrix.pm-version-major }}*.tar.gz
122-
install.log
123-
compile.sh
124-
if-no-files-found: error
125-
126-
- name: Prepare workspace for upload
127-
if: failure()
128-
run: tar -czf workspace.tar.gz install_data
129-
130-
- name: Upload workspace
131-
uses: actions/upload-artifact@v4
132-
if: failure()
133-
with:
134-
name: MacOS-${{ matrix.artifact-name }}-workspace-PM${{ matrix.pm-version-major }}
135-
path: |
136-
workspace.tar.gz
137-
if-no-files-found: error
138-
139-
windows:
140-
name: Windows (PM ${{ matrix.pm-version-major }})
141-
runs-on: windows-2019
142-
strategy:
143-
matrix:
144-
pm-version-major: [ 4, 5 ]
145-
146-
steps:
147-
- uses: actions/checkout@v4
148-
149-
- name: Install tools and dependencies
150-
run: choco install wget --no-progress
151-
152-
- name: Compile PHP
153-
run: .\windows-compile-vs.bat
154-
env:
155-
VS_EDITION: Enterprise
156-
SOURCES_PATH: ${{ github.workspace }}\pocketmine-php-sdk
157-
PM_VERSION_MAJOR: ${{ matrix.pm-version-major }}
158-
159-
- name: Rename artifacts
160-
run: |
161-
mkdir temp
162-
move php-debug-pack-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}-debugging-symbols.zip
163-
move php-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}.zip
164-
move temp\*.zip .
165-
166-
- name: Upload artifacts
167-
uses: actions/upload-artifact@v4
168-
if: always()
169-
with:
170-
name: Windows-PM${{ matrix.pm-version-major }}
171-
path: |
172-
PHP-Windows-x64*.zip
173-
compile.log
174-
windows-compile-vs.bat
175-
if-no-files-found: error
22+
uses: ./.github/workflows/main-pm-matrix.yml
23+
with:
24+
pm-version-major: ${{ matrix.pm-version-major }}
25+
secrets: inherit
17626

17727
publish:
17828
name: Publish binaries
179-
needs: [linux, macos, windows]
29+
needs: [all-builds]
18030
runs-on: ubuntu-20.04
18131
if: ${{ startsWith(github.ref_name, 'php/') && github.ref_type == 'branch' && !contains(github.event.head_commit.message, '[no release]') }}
18232

0 commit comments

Comments
 (0)