@@ -3,6 +3,7 @@ name: Build binary releases
33concurrency :
44 cancel-in-progress : true
55 group : ${{ github.workflow }}-${{ github.ref }}
6+
67on :
78 pull_request :
89 branches :
3031 type : string
3132 schedule :
3233 - cron : " 0 0 * * *"
34+
3335permissions :
34- contents : write
35- id-token : write
36- attestations : write
36+ contents : read
37+
3738env :
3839 IMAGE_NAME : ${{ (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.version) || startsWith(github.ref, 'refs/tags/')) && 'dunglas/frankenphp' || 'dunglas/frankenphp-dev' }}
3940 GOTOOLCHAIN : local
41+
4042jobs :
4143 prepare :
4244 runs-on : ubuntu-24.04
@@ -51,17 +53,19 @@ jobs:
5153 id : check
5254 if : github.event_name == 'schedule'
5355 run : |
54- ref="${{ (github.ref_type == 'tag' && github.ref_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' } }"
56+ ref="${REF }"
5557 if [[ -z "${ref}" ]]; then
5658 ref="$(gh release view --repo dunglas/frankenphp --json tagName --jq '.tagName')"
5759 fi
5860
5961 echo "ref=${ref}" >> "${GITHUB_OUTPUT}"
6062 env :
6163 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+ REF : ${{ (github.ref_type == 'tag' && github.ref_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }}
6265 - uses : actions/checkout@v5
6366 with :
6467 ref : ${{ steps.check.outputs.ref }}
68+ persist-credentials : false
6569 - name : Set up Docker Buildx
6670 uses : docker/setup-buildx-action@v3
6771 - name : Create platforms matrix
7781 env :
7882 SHA : ${{ github.sha }}
7983 VERSION : ${{ steps.check.outputs.ref || 'dev' }}
84+
8085 build-linux-musl :
86+ permissions :
87+ contents : write
88+ id-token : write
89+ attestations : write
8190 strategy :
8291 fail-fast : false
8392 matrix :
@@ -96,12 +105,13 @@ jobs:
96105 steps :
97106 - name : Prepare
98107 id : prepare
99- run : |
100- platform=${{ matrix.platform }}
101- echo "sanitized_platform=${ platform//\//-}" >> "${GITHUB_OUTPUT}"
108+ run : echo "sanitized_platform=${PLATFORM//\//-}" >> "${GITHUB_OUTPUT}"
109+ env :
110+ PLATFORM : ${{ matrix. platform }}
102111 - uses : actions/checkout@v5
103112 with :
104113 ref : ${{ needs.prepare.outputs.ref }}
114+ persist-credentials : false
105115 - name : Set up Docker Buildx
106116 uses : docker/setup-buildx-action@v3
107117 with :
@@ -156,11 +166,12 @@ jobs:
156166 run : |
157167 # shellcheck disable=SC2034
158168 digest=$(jq -r '."static-builder-musl"."${{ (fromJson(needs.prepare.outputs.push) && !matrix.debug && !matrix.mimalloc) && 'containerimage.digest' || 'containerimage.config.digest' }}"' <<< "${METADATA}")
159- docker create --platform=${{ matrix.platform }} --name static-builder-musl "${{ (fromJson(needs.prepare.outputs.push) && !matrix.debug && !matrix.mimalloc) && '${IMAGE_NAME}@${digest}' || '${digest}' }}"
169+ docker create --platform="${PLATFORM}" --name static-builder-musl "${{ (fromJson(needs.prepare.outputs.push) && !matrix.debug && !matrix.mimalloc) && '${IMAGE_NAME}@${digest}' || '${digest}' }}"
160170 docker cp "static-builder-musl:/go/src/app/dist/${BINARY}" "${BINARY}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }}"
161171 env :
162172 METADATA : ${{ steps.build.outputs.metadata }}
163173 BINARY : frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}
174+ PLATFORM : ${{ matrix.platform }}
164175 - name : Upload artifact
165176 if : ${{ !fromJson(needs.prepare.outputs.push) }}
166177 uses : actions/upload-artifact@v4
@@ -169,9 +180,10 @@ jobs:
169180 path : frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }}
170181 - name : Upload assets
171182 if : fromJson(needs.prepare.outputs.push) && (needs.prepare.outputs.ref || github.ref_type == 'tag')
172- run : gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref } }" frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }} --repo dunglas/frankenphp --clobber
183+ run : gh release upload "${REF }" frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }} --repo dunglas/frankenphp --clobber
173184 env :
174185 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
186+ REF : ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}
175187 - if : fromJson(needs.prepare.outputs.push) && (needs.prepare.outputs.ref || github.ref_type == 'tag')
176188 uses : actions/attest-build-provenance@v2
177189 with :
@@ -190,6 +202,10 @@ jobs:
190202 BINARY : ./frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }}
191203
192204 build-linux-gnu :
205+ permissions :
206+ contents : write
207+ id-token : write
208+ attestations : write
193209 strategy :
194210 fail-fast : false
195211 matrix :
@@ -200,12 +216,13 @@ jobs:
200216 steps :
201217 - name : Prepare
202218 id : prepare
203- run : |
204- platform=${{ matrix.platform }}
205- echo "sanitized_platform=${ platform//\//-}" >> "${GITHUB_OUTPUT}"
219+ run : echo "sanitized_platform=${PLATFORM//\//-}" >> "${GITHUB_OUTPUT}"
220+ env :
221+ PLATFORM : ${{ matrix. platform }}
206222 - uses : actions/checkout@v5
207223 with :
208224 ref : ${{ needs.prepare.outputs.ref }}
225+ persist-credentials : false
209226 - name : Set up Docker Buildx
210227 uses : docker/setup-buildx-action@v3
211228 with :
@@ -259,7 +276,7 @@ jobs:
259276 run : |
260277 # shellcheck disable=SC2034
261278 digest=$(jq -r '."static-builder-gnu"."${{ fromJson(needs.prepare.outputs.push) && 'containerimage.digest' || 'containerimage.config.digest' }}"' <<< "${METADATA}")
262- container_id=$(docker create --platform=${{ matrix.platform }} "${{ fromJson(needs.prepare.outputs.push) && '${IMAGE_NAME}@${digest}' || '${digest}' }}")
279+ container_id=$(docker create --platform="${PLATFORM}" "${{ fromJson(needs.prepare.outputs.push) && '${IMAGE_NAME}@${digest}' || '${digest}' }}")
263280 mkdir -p gh-output
264281 cd gh-output
265282 for file in $(docker run --rm "${{ fromJson(needs.prepare.outputs.push) && '${IMAGE_NAME}@${digest}' || '${digest}' }}" sh -c "ls /go/src/app/dist | grep '^frankenphp'"); do
@@ -270,6 +287,7 @@ jobs:
270287 env :
271288 METADATA : ${{ steps.build.outputs.metadata }}
272289 BINARY : frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}
290+ PLATFORM : ${{ matrix.platform }}
273291 - name : Upload artifact
274292 if : ${{ !fromJson(needs.prepare.outputs.push) }}
275293 uses : actions/upload-artifact@v4
@@ -278,9 +296,10 @@ jobs:
278296 path : gh-output/*
279297 - name : Upload assets
280298 if : fromJson(needs.prepare.outputs.push) && (needs.prepare.outputs.ref || github.ref_type == 'tag')
281- run : gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref } }" gh-output/* --repo dunglas/frankenphp --clobber
299+ run : gh release upload "${REF }" gh-output/* --repo dunglas/frankenphp --clobber
282300 env :
283301 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
302+ REF : ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}
284303 - if : fromJson(needs.prepare.outputs.push) && (needs.prepare.outputs.ref || github.ref_type == 'tag')
285304 uses : actions/attest-build-provenance@v2
286305 with :
@@ -356,6 +375,10 @@ jobs:
356375 GNU_METADATA : ${{ needs.prepare.outputs.gnu_metadata }}
357376
358377 build-mac :
378+ permissions :
379+ contents : write
380+ id-token : write
381+ attestations : write
359382 strategy :
360383 fail-fast : false
361384 matrix :
@@ -369,23 +392,27 @@ jobs:
369392 - uses : actions/checkout@v5
370393 with :
371394 ref : ${{ needs.prepare.outputs.ref }}
395+ persist-credentials : false
372396 - uses : actions/setup-go@v5
373397 with :
374398 go-version : " 1.25"
375399 cache-dependency-path : |
376400 go.sum
377401 caddy/go.sum
402+ cache : false
378403 - name : Set FRANKENPHP_VERSION
379404 run : |
380405 if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
381406 export FRANKENPHP_VERSION=${GITHUB_REF_NAME:1}
382407 elif [ "${GITHUB_EVENT_NAME}" == "schedule" ]; then
383- export FRANKENPHP_VERSION="${{ needs.prepare.outputs.ref } }"
408+ export FRANKENPHP_VERSION="${REF }"
384409 else
385410 export FRANKENPHP_VERSION=${GITHUB_SHA}
386411 fi
387412
388413 echo "FRANKENPHP_VERSION=${FRANKENPHP_VERSION}" >> "${GITHUB_ENV}"
414+ env :
415+ REF : ${{ needs.prepare.outputs.ref }}
389416 - name : Build FrankenPHP
390417 run : ./build-static.sh
391418 env :
0 commit comments