-
Notifications
You must be signed in to change notification settings - Fork 72
142 lines (122 loc) · 5.63 KB
/
build-php-windows.yml
File metadata and controls
142 lines (122 loc) · 5.63 KB
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
name: Build Self-Hosted PHP Binary (Windows)
on:
workflow_dispatch:
schedule:
- cron: "0 1 */3 * *"
jobs:
build-release-artifacts:
name: "Build ${{ matrix.php-version }}-${{ matrix.combination }} on ${{ matrix.runner }}"
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
runner:
- "windows-latest"
combination:
- spc-min
- spc-max
steps:
- name: "Process env string"
id: process-env
run: |
switch ("${{ matrix.combination }}") {
"spc-min" {
Add-Content -Path $env:GITHUB_OUTPUT -Value "EXTENSIONS=ctype,fileinfo,filter,iconv,mbstring,tokenizer,phar"
Add-Content -Path $env:GITHUB_OUTPUT -Value "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_WINDOWS_SPC_MIN }}"
}
"spc-max" {
Add-Content -Path $env:GITHUB_OUTPUT -Value "EXTENSIONS=amqp,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,ds,exif,ffi,fileinfo,filter,ftp,gd,iconv,igbinary,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pdo,pdo_mysql,pdo_sqlite,pdo_sqlsrv,phar,rar,redis,session,shmop,simdjson,simplexml,soap,sockets,sqlite3,sqlsrv,ssh2,sysvshm,tokenizer,xml,xmlreader,xmlwriter,yac,yaml,zip,zlib"
Add-Content -Path $env:GITHUB_OUTPUT -Value "DEPLOY_TARGET=${{ secrets.DEPLOY_SERVER_TARGET_WINDOWS_SPC_MAX }}"
}
}
switch ("${{ matrix.runner }}") {
"windows-latest" {
Add-Content -Path $env:GITHUB_OUTPUT -Value "OS=windows"
Add-Content -Path $env:GITHUB_OUTPUT -Value "ARCH=x86_64"
Add-Content -Path $env:GITHUB_OUTPUT -Value "CMD=bin/spc"
}
}
- name: "Checkout remote"
if: github.repository != 'crazywhalecc/static-php-cli'
uses: actions/checkout@v4
with:
repository: crazywhalecc/static-php-cli
ref: main
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
tools: pecl, composer
extensions: curl, openssl, mbstring, filter
ini-values: memory_limit=-1
- name: "Cache composer packages"
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php
# Cache downloaded source
- id: cache-download
uses: actions/cache@v4
with:
path: downloads
key: pack-lib-dependencies-${{ matrix.combination }}-${{ matrix.php-version }}-${{ matrix.runner }}
- name: "Install Dependencies"
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --no-dev
- name: "Validate SPC powershell script"
run: ${{ steps.process-env.outputs.CMD }} --version
- name: "Run Build Tests (doctor)"
run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix
# If there's no dependencies cache, fetch sources
- name: "Download sources"
env:
GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }}
run: ${{ steps.process-env.outputs.CMD }} download --with-php=${{ matrix.php-version }} --for-extensions="${{ steps.process-env.outputs.EXTENSIONS }}" --retry=5 --prefer-pre-built --ignore-cache-sources=php-src
- name: "Doctor"
env:
GITHUB_TOKEN: ${{ secrets.S_GITHUB_TOKEN }}
run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix
- name: "Install UPX"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ${{ steps.process-env.outputs.CMD }} install-pkg upx
- name: "Build extensions: ${{ steps.process-env.outputs.EXTENSIONS }}"
run: ${{ steps.process-env.outputs.CMD }} build --build-cli --build-micro "${{ steps.process-env.outputs.EXTENSIONS }}" --debug --with-upx-pack
- name: "Pack PHP"
run: |
$PHPVER = ${{ steps.process-env.outputs.CMD }} dev:php-ver
New-Item -ItemType Directory -Force -Path dist
Compress-Archive -Path "buildroot\bin\php.exe" -DestinationPath "dist\php-$PHPVER-cli-win.zip"
Compress-Archive -Path "buildroot\bin\micro.sfx" -DestinationPath "dist\php-$PHPVER-micro-win.zip"
ls dist
echo ("PHPVER=" + $PHPVER) >> $env:GITHUB_ENV
- name: "Add README for ${{ matrix.combination }}"
if: ${{ matrix.php-version == '8.4' }}
shell: bash
run: |
echo -e "# Note\n\nCurrent distribution uses extensions:\n\n${{ steps.process-env.outputs.EXTENSIONS }}\n\nUsing compile command:\n\n bin/spc build --build-cli --build-micro \"${{ steps.process-env.outputs.EXTENSIONS }}\" --debug --with-upx-pack" > dist/README.txt
- name: "Deploy to self-hosted OSS"
uses: static-php/upload-s3-action@v1.0.0
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: "dist/"
destination_dir: static-php-cli/windows/${{ matrix.combination }}/
endpoint: ${{ secrets.AWS_ENDPOINT }}
- name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
name: php-${{ matrix.php-version }}-windows-${{ matrix.combination }}
path: |
buildroot/bin/php.exe
buildroot/bin/micro.sfx
if-no-files-found: error