Skip to content

Commit 5ef0cd9

Browse files
committed
ci: factor FRANKENPHP_VERSION resolution and setup-php into composite actions
1 parent 9d1cfc3 commit 5ef0cd9

6 files changed

Lines changed: 55 additions & 59 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: setup-php
2+
description: Setup PHP in ZTS + debug mode with FrankenPHP's standard configuration
3+
inputs:
4+
php-version:
5+
description: PHP version (e.g. "8.5")
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- uses: shivammathur/setup-php@v2
11+
with:
12+
php-version: ${{ inputs.php-version }}
13+
ini-file: development
14+
coverage: none
15+
tools: none
16+
env:
17+
phpts: ts
18+
debug: true
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: version
2+
description: Resolve FRANKENPHP_VERSION from the current ref (stripped tag name, with commit SHA fallback)
3+
inputs:
4+
ref:
5+
description: Optional ref override (e.g. tag name resolved by a prepare job for schedule/dispatch flows)
6+
required: false
7+
default: ""
8+
runs:
9+
using: composite
10+
steps:
11+
- shell: bash
12+
env:
13+
REF: ${{ inputs.ref }}
14+
run: | # zizmor: ignore[github-env]
15+
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
16+
version="${GITHUB_REF_NAME#v}"
17+
elif [ -n "${REF}" ]; then
18+
version="${REF#v}"
19+
else
20+
version="${GITHUB_SHA}"
21+
fi
22+
if [[ ! "${version}" =~ ^[A-Za-z0-9._-]+$ ]]; then
23+
echo "::error::invalid FRANKENPHP_VERSION value: ${version}" >&2
24+
exit 1
25+
fi
26+
echo "FRANKENPHP_VERSION=${version}" >> "${GITHUB_ENV}"

.github/workflows/pgo-profile.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ jobs:
3636
# persist-credentials is intentionally left enabled because this
3737
# workflow needs to push a branch via git push (mirrors translate.yaml).
3838
- uses: ./.github/actions/setup-go
39-
- uses: shivammathur/setup-php@v2
39+
- uses: ./.github/actions/setup-php
4040
with:
4141
php-version: "8.5"
42-
ini-file: development
43-
coverage: none
44-
tools: none
45-
env:
46-
phpts: ts
47-
debug: true
4842
- name: Install e-dant/watcher
4943
uses: ./.github/actions/watcher
5044
- name: Set CGO flags

.github/workflows/static.yaml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,9 @@ jobs:
453453
ref: ${{ needs.prepare.outputs.ref }}
454454
persist-credentials: false
455455
- uses: ./.github/actions/setup-go
456-
- name: Set FRANKENPHP_VERSION
457-
run: |
458-
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
459-
export FRANKENPHP_VERSION=${GITHUB_REF_NAME:1}
460-
elif [ "${GITHUB_EVENT_NAME}" == "schedule" ]; then
461-
export FRANKENPHP_VERSION="${REF}"
462-
else
463-
export FRANKENPHP_VERSION=${GITHUB_SHA}
464-
fi
465-
466-
echo "FRANKENPHP_VERSION=${FRANKENPHP_VERSION}" >> "${GITHUB_ENV}"
467-
env:
468-
REF: ${{ needs.prepare.outputs.ref }}
456+
- uses: ./.github/actions/version
457+
with:
458+
ref: ${{ needs.prepare.outputs.ref }}
469459
- name: Build FrankenPHP
470460
run: ./build-static.sh
471461
env:

.github/workflows/tests.yaml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,9 @@ jobs:
4242
with:
4343
persist-credentials: false
4444
- uses: ./.github/actions/setup-go
45-
- uses: shivammathur/setup-php@v2
45+
- uses: ./.github/actions/setup-php
4646
with:
4747
php-version: ${{ matrix.php-versions }}
48-
ini-file: development
49-
coverage: none
50-
tools: none
51-
env:
52-
phpts: ts
53-
debug: true
5448
- name: Install e-dant/watcher
5549
uses: ./.github/actions/watcher
5650
- name: Reinstall libbrotli-dev
@@ -113,15 +107,9 @@ jobs:
113107
with:
114108
persist-credentials: false
115109
- uses: ./.github/actions/setup-go
116-
- uses: shivammathur/setup-php@v2
110+
- uses: ./.github/actions/setup-php
117111
with:
118112
php-version: ${{ matrix.php-versions }}
119-
ini-file: development
120-
coverage: none
121-
tools: none
122-
env:
123-
phpts: ts
124-
debug: true
125113
- name: Install PHP development libraries
126114
run: sudo apt-get update && sudo apt-get install -y libkrb5-dev libsodium-dev libargon2-dev
127115
- name: Install xcaddy
@@ -152,15 +140,9 @@ jobs:
152140
with:
153141
persist-credentials: false
154142
- uses: ./.github/actions/setup-go
155-
- uses: shivammathur/setup-php@v2
143+
- uses: ./.github/actions/setup-php
156144
with:
157-
php-version: 8.5
158-
ini-file: development
159-
coverage: none
160-
tools: none
161-
env:
162-
phpts: ts
163-
debug: true
145+
php-version: "8.5"
164146
- name: Install gotestsum
165147
run: go install gotest.tools/gotestsum@latest
166148
- name: Set CGO flags

.github/workflows/windows.yaml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,9 @@ jobs:
6969
path: frankenphp
7070
persist-credentials: false
7171

72-
- name: Set FRANKENPHP_VERSION
73-
run: |
74-
$ref = $env:REF
75-
76-
if ($env:GITHUB_REF_TYPE -eq "tag") {
77-
$frankenphpVersion = $env:GITHUB_REF_NAME.Substring(1)
78-
} elseif ($ref) {
79-
if ($ref.StartsWith("v")) {
80-
$frankenphpVersion = $ref.Substring(1)
81-
} else {
82-
$frankenphpVersion = $ref
83-
}
84-
} else {
85-
$frankenphpVersion = $env:GITHUB_SHA
86-
}
87-
88-
"FRANKENPHP_VERSION=$frankenphpVersion" >> $env:GITHUB_ENV
72+
- uses: ./frankenphp/.github/actions/version
73+
with:
74+
ref: ${{ env.REF }}
8975

9076
- name: Setup Go
9177
uses: ./frankenphp/.github/actions/setup-go

0 commit comments

Comments
 (0)