-
Notifications
You must be signed in to change notification settings - Fork 171
224 lines (189 loc) · 7.31 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: Build PHP binaries
on:
push:
branches: "**"
tags-ignore: "php-**"
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linux:
name: Linux (PM ${{ matrix.pm-version-major }})
runs-on: ubuntu-20.04
strategy:
matrix:
pm-version-major: [4, 5]
steps:
- uses: actions/checkout@v3
- 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@v3
with:
path: ./download_cache
key: compile-sh-cache-${{ hashFiles('./compile.sh') }}
restore-keys: compile-sh-cache-
- 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 -f -g -P ${{ matrix.pm-version-major }} -c ./download_cache
- name: Create tarball
run: tar -czf ./PHP-Linux-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: Linux-PM${{ matrix.pm-version-major }}
path: |
./PHP-Linux-x86_64-PM${{ matrix.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@v3
if: failure()
with:
name: Linux-workspace-PM${{ matrix.pm-version-major }}
path: |
workspace.tar.gz
if-no-files-found: error
macos:
name: MacOS (PM ${{ matrix.pm-version-major }})
runs-on: macos-11.0
strategy:
matrix:
pm-version-major: [ 4, 5 ]
steps:
- uses: actions/checkout@v3
- name: Install tools and dependencies
run: brew install libtool autoconf automake pkg-config bison re2c
- name: Prepare compile.sh download cache
id: download-cache
uses: actions/cache@v3
with:
path: ./download_cache
key: compile-sh-cache-${{ hashFiles('./compile.sh') }}
restore-keys: compile-sh-cache-
- name: Compile PHP
run: |
export PATH="/usr/local/opt/bison/bin:$PATH"
set -ex
trap "exit 1" ERR
./compile.sh -t mac-x86-64 -j4 -f -g -P ${{ matrix.pm-version-major }} -c ./download_cache
- name: Create tarball
run: tar -czf ./PHP-MacOS-x86_64-PM${{ matrix.pm-version-major }}.tar.gz bin
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: MacOS-PM${{ matrix.pm-version-major }}
path: |
./PHP-MacOS-x86_64-PM${{ matrix.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@v3
if: failure()
with:
name: MacOS-workspace-PM${{ matrix.pm-version-major }}
path: |
workspace.tar.gz
if-no-files-found: error
windows:
name: Windows (PM ${{ matrix.pm-version-major }})
runs-on: windows-2019
strategy:
matrix:
pm-version-major: [ 4, 5 ]
steps:
- uses: actions/checkout@v3
- name: Install tools and dependencies
run: choco install wget --no-progress
- name: Compile PHP
run: .\windows-compile-vs.bat
env:
VS_EDITION: Enterprise
SOURCES_PATH: ${{ github.workspace }}\pocketmine-php-sdk
PM_VERSION_MAJOR: ${{ matrix.pm-version-major }}
- name: Rename artifacts
run: |
mkdir temp
move php-debug-pack-*.zip temp/PHP-Windows-x64-debug-pack-PM${{ matrix.pm-version-major }}.zip
move php-*.zip temp/PHP-Windows-x64-PM${{ matrix.pm-version-major }}.zip
move temp\*.zip .
- name: Upload artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: Windows-PM${{ matrix.pm-version-major }}
path: |
PHP-Windows-x64*.zip
compile.log
windows-compile-vs.bat
if-no-files-found: error
publish:
name: Publish binaries
needs: [linux, macos, windows]
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref_name, 'php/') && github.ref_type == 'branch' && !contains(github.event.head_commit.message, '[no release]') }}
steps:
- uses: actions/checkout@v3
- name: Set version information
id: version
run: |
echo PHP_VERSION=$(echo ${{ github.ref_name }} | cut -d / -f2) >> $GITHUB_OUTPUT
- name: Update latest tag target
run: |
git tag -f php-${{ steps.version.outputs.PHP_VERSION }}-latest
git push -f origin php-${{ steps.version.outputs.PHP_VERSION }}-latest
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}
- name: Generate release notes
run: |
echo "Built by: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" > changelog.md
if [[ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]]; then
echo -e "\n\n\n" >> changelog.md
echo ":warning: **This isn't the currently recommended version for PocketMine-MP.**" >> changelog.md
echo "Consider using the [recommended release](${{ github.server_url }}/${{ github.repository }}/releases/latest) instead." >> changelog.md
fi
- name: Update latest branch release
uses: ncipollo/release-action@v1.12.0
with:
artifacts: |
${{ github.workspace }}/Linux-PM*/*.tar.gz
${{ github.workspace }}/MacOS-PM*/*.tar.gz
${{ github.workspace }}/Windows-PM*/*.zip
makeLatest: ${{ github.ref_name == github.event.repository.default_branch }}
name: PHP ${{ steps.version.outputs.PHP_VERSION }} (Latest)
tag: php-${{ steps.version.outputs.PHP_VERSION }}-latest
commit: ${{ github.sha }}
allowUpdates: true
bodyFile: ${{ github.workspace }}/changelog.md
- name: Publish unique release
uses: ncipollo/release-action@v1.12.0
with:
artifacts: |
${{ github.workspace }}/Linux-PM*/*.tar.gz
${{ github.workspace }}/MacOS-PM*/*.tar.gz
${{ github.workspace }}/Windows-PM*/*.zip
makeLatest: false
name: PHP ${{ steps.version.outputs.PHP_VERSION }} (Build ${{ github.run_number }})
tag: php-${{ steps.version.outputs.PHP_VERSION }}-build-${{ github.run_number }}
commit: ${{ github.sha }}
bodyFile: ${{ github.workspace }}/changelog.md