forked from crazywhalecc/static-php-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (156 loc) · 5.99 KB
/
release-build.yml
File metadata and controls
175 lines (156 loc) · 5.99 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
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
name: Build SPC Binary
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths:
- '.github/workflows/release-build.yml'
release:
types:
- published
workflow_dispatch:
env:
PHP_VERSION: 8.4
MICRO_VERSION: 8.4.11
jobs:
build-release-artifacts:
name: "Build SPC Binary for ${{ matrix.operating-system.name }}"
runs-on: ${{ matrix.operating-system.os }}
strategy:
matrix:
operating-system:
- name: "linux-x86_64"
os: "ubuntu-latest"
filename: "spc-linux-x86_64.tar.gz"
- name: "macos-x86_64"
os: "macos-15-intel"
filename: "spc-macos-x86_64.tar.gz"
- name: "linux-aarch64"
os: "ubuntu-latest"
filename: "spc-linux-aarch64.tar.gz"
- name: "macos-aarch64"
os: "macos-14"
filename: "spc-macos-aarch64.tar.gz"
- name: "windows-x64"
os: "ubuntu-latest"
filename: "spc-windows-x64.exe"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- if: inputs.debug == true
run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV
- name: "Install PHP for official runners"
uses: shivammathur/setup-php@v2
with:
coverage: none
tools: composer:v2
php-version: "${{ env.PHP_VERSION }}"
ini-values: memory_limit=-1
extensions: curl, openssl, mbstring
- name: "Get Composer Cache Directory"
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: "Cache Composer dependencies"
uses: "actions/cache@v4"
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: "php-${{ env.PHP_VERSION }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
restore-keys: |
php-${{ env.PHP_VERSION }}-locked-composer
- name: "Install Locked Dependencies"
run: "composer install --no-interaction --no-progress"
- name: "Build PHAR File"
run: "composer build:phar"
- name: "Download Minimal Combination"
run: |
if [ "${{ matrix.operating-system.name }}" = "windows-x64" ]; then
curl -fsSL https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ env.MICRO_VERSION }}-micro-win.zip -o tmp.zip
unzip tmp.zip
else
curl -fsSL https://dl.static-php.dev/static-php-cli/minimal/php-${{ env.MICRO_VERSION }}-micro-${{ matrix.operating-system.name }}.tar.gz -o tmp.tgz
tar -zxvf tmp.tgz
fi
- name: "Generate Executable"
run: |
bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G"
if [ "${{ matrix.operating-system.name }}" = "windows-x64" ]; then
mv spc spc.exe
else
chmod +x spc
fi
if [ "${{ matrix.operating-system.name }}" = "macos-aarch64" ] || [ "${{ matrix.operating-system.name }}" = "macos-x86_64" ]; then
sudo xattr -cr ./spc
fi
- name: "Archive Executable and Validate Binary"
run: |
if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then
tar -czf ${{ matrix.operating-system.filename }} spc
# validate spc binary
if [ "${{ matrix.operating-system.name }}" == "linux-x86_64" ]; then
./spc dev:extensions
fi
fi
- name: "Copy file"
run: |
if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then
mkdir dist/ && cp ${{ matrix.operating-system.filename }} dist/ && cp spc dist/spc-${{ matrix.operating-system.name }}
else
mkdir dist/ && cp spc.exe dist/${{ matrix.operating-system.filename }}
echo "SUFFIX=.exe" >> $GITHUB_ENV
fi
- name: "Upload Binaries to Release"
uses: softprops/action-gh-release@v1
if: ${{startsWith(github.ref, 'refs/tags/') }}
with:
files: dist/${{ matrix.operating-system.filename }}
- name: "Deploy to self-hosted OSS"
# only run this step if the repository is static-php-cli and the branch is main
if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main'
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/spc-bin/nightly/
endpoint: ${{ secrets.AWS_ENDPOINT }}
- name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
path: spc${{ env.SUFFIX }}
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
test-spc:
name: "Test SPC Binary for ${{ matrix.operating-system.name }}"
runs-on: ${{ matrix.operating-system.os }}
needs: [build-release-artifacts]
strategy:
matrix:
operating-system:
- name: "linux-x86_64"
os: "ubuntu-latest"
- name: "macos-x86_64"
os: "macos-15-intel"
- name: "linux-aarch64"
os: "ubuntu-24.04-arm"
- name: "macos-aarch64"
os: "macos-15"
- name: "windows-x64"
os: "windows-latest"
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Download Artifact"
uses: actions/download-artifact@v4
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
with:
name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }}
- name: "Chmod"
if: matrix.operating-system.name != 'windows-x64'
run: chmod +x spc
- name: "Run SPC Tests"
env:
SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }}
run: ./spc${{ env.SUFFIX }} dev:extensions