-
Notifications
You must be signed in to change notification settings - Fork 5
262 lines (228 loc) · 7.37 KB
/
Copy pathphp-release.yml
File metadata and controls
262 lines (228 loc) · 7.37 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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: PHP Release
on:
push:
tags:
- 'php-v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.2.0)'
required: true
env:
CARGO_TERM_COLOR: always
EXT_NAME: stateset_embedded
permissions:
contents: read
jobs:
release_hygiene:
name: Release Hygiene
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: |
package-lock.json
cli/package-lock.json
- name: Install root tooling
run: HUSKY=0 npm ci
- name: Install CLI dependencies
working-directory: cli
run: npm ci
- name: Check release hygiene
env:
RELEASE_VERSION: ${{ inputs.version || '' }}
run: bash ./scripts/ci/check_release_hygiene.sh
build:
name: Build (${{ matrix.os }}-${{ matrix.php }})
runs-on: ${{ matrix.os }}
needs: release_hygiene
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- os: ubuntu-latest
php: '8.1'
target: x86_64-unknown-linux-gnu
artifact: linux-x86_64-php81
- os: ubuntu-latest
php: '8.2'
target: x86_64-unknown-linux-gnu
artifact: linux-x86_64-php82
- os: ubuntu-latest
php: '8.3'
target: x86_64-unknown-linux-gnu
artifact: linux-x86_64-php83
# macOS x86_64
- os: macos-13
php: '8.2'
target: x86_64-apple-darwin
artifact: darwin-x86_64-php82
# macOS arm64
- os: macos-14
php: '8.2'
target: aarch64-apple-darwin
artifact: darwin-arm64-php82
- os: macos-14
php: '8.3'
target: aarch64-apple-darwin
artifact: darwin-arm64-php83
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
extensions: ffi
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cargo-php (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y php${{ matrix.php }}-dev clang llvm
cargo install cargo-php
- name: Install cargo-php (macOS)
if: runner.os == 'macOS'
run: cargo install cargo-php
- name: Build extension
working-directory: bindings/php
run: |
cargo build --release --target ${{ matrix.target }}
mkdir -p dist
if [ "${{ runner.os }}" = "Linux" ]; then
cp ../../target/${{ matrix.target }}/release/libstateset_embedded.so dist/${{ env.EXT_NAME }}.so
else
cp ../../target/${{ matrix.target }}/release/libstateset_embedded.dylib dist/${{ env.EXT_NAME }}.dylib
fi
- name: Package extension
working-directory: bindings/php
run: |
tar -czvf ${{ env.EXT_NAME }}-${{ matrix.artifact }}.tar.gz \
-C dist .
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: php-ext-${{ matrix.artifact }}
path: bindings/php/${{ env.EXT_NAME }}-${{ matrix.artifact }}.tar.gz
retention-days: 7
if-no-files-found: error
# Windows builds
build-windows:
name: Build (Windows-${{ matrix.php }})
runs-on: windows-latest
needs: release_hygiene
strategy:
matrix:
php: ['8.2', '8.3']
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
- name: Install Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
- name: Build extension
working-directory: bindings/php
shell: pwsh
run: |
cargo build --release
New-Item -ItemType Directory -Force -Path dist
Copy-Item "..\..\target\release\stateset_embedded.dll" "dist\php_${{ env.EXT_NAME }}.dll"
- name: Package extension
working-directory: bindings/php
shell: pwsh
run: |
Compress-Archive -Path dist\* -DestinationPath "${{ env.EXT_NAME }}-windows-x86_64-php${{ matrix.php }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: php-ext-windows-x86_64-php${{ matrix.php }}
path: bindings/php/${{ env.EXT_NAME }}-windows-x86_64-php${{ matrix.php }}.zip
retention-days: 7
if-no-files-found: error
publish:
name: Create Release
needs: [release_hygiene, build, build-windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
pattern: php-ext-*
merge-multiple: true
- name: Generate release checksums
run: |
sha256sum artifacts/* > release-checksums.txt
- name: Attest release artifacts
uses: actions/attest-build-provenance@v3
with:
subject-path: |
artifacts/*
release-checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228
with:
files: |
artifacts/*
release-checksums.txt
generate_release_notes: true
body: |
## PHP Extension: StateSet Embedded Commerce
### Installation
1. Download the appropriate binary for your platform
2. Extract to your PHP extensions directory
3. Add `extension=stateset_embedded` to php.ini
4. Install Composer package: `composer require stateset/embedded`
### Platforms
- Linux x86_64 (PHP 8.1, 8.2, 8.3)
- macOS x86_64 (PHP 8.2)
- macOS arm64 (PHP 8.2, 8.3)
- Windows x86_64 (PHP 8.2, 8.3)
### Release verification
```text
sha256sum -c release-checksums.txt
```
# Update Packagist
packagist:
name: Notify Packagist
needs: publish
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
steps:
- name: Notify Packagist
run: |
curl -X POST \
-H "Content-Type: application/json" \
-d '{"repository":{"url":"https://github.com/stateset/stateset-icommerce"}}' \
"https://packagist.org/api/update-package?username=${{ secrets.PACKAGIST_USERNAME }}&apiToken=${{ secrets.PACKAGIST_API_TOKEN }}"