3636 push : ${{ toJson((steps.check.outputs.ref || (github.event_name == 'workflow_dispatch' && inputs.version) || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) && true || false) }}
3737 platforms : ${{ steps.matrix.outputs.platforms }}
3838 metadata : ${{ steps.matrix.outputs.metadata }}
39+ gnu_metadata : ${{ steps.matrix.outputs.gnu_metadata }}
3940 ref : ${{ steps.check.outputs.ref }}
4041 steps :
4142 - name : Get version
5960 id : matrix
6061 run : |
6162 METADATA="$(docker buildx bake --print static-builder | jq -c)"
63+ GNU_METADATA="$(docker buildx bake --print gnu-static | jq -c)"
6264 {
6365 echo metadata="${METADATA}"
6466 echo platforms="$(jq -c 'first(.target[]) | .platforms' <<< "${METADATA}")"
67+ echo gnu_metadata="${GNU_METADATA}"
6568 } >> "${GITHUB_OUTPUT}"
6669 env :
6770 SHA : ${{ github.sha }}
@@ -176,12 +179,113 @@ jobs:
176179 env :
177180 BINARY : ./frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}${{ matrix.debug && '-debug' || '' }}${{ matrix.mimalloc && '-mimalloc' || '' }}
178181
182+ build-linux-gnu :
183+ strategy :
184+ fail-fast : false
185+ matrix :
186+ platform : ${{ fromJson(needs.prepare.outputs.platforms) }}
187+ name : Build ${{ matrix.platform }} GNU static binary
188+ runs-on : ubuntu-24.04
189+ needs : [prepare]
190+ steps :
191+ - name : Prepare
192+ id : prepare
193+ run : |
194+ platform=${{ matrix.platform }}
195+ echo "sanitized_platform=${platform//\//-}" >> "${GITHUB_OUTPUT}"
196+ - uses : actions/checkout@v4
197+ with :
198+ ref : ${{ needs.prepare.outputs.ref }}
199+ - name : Set up Docker Buildx
200+ uses : docker/setup-buildx-action@v3
201+ with :
202+ platforms : ${{ matrix.platform }}
203+ - name : Login to DockerHub
204+ if : ${{ fromJson(needs.prepare.outputs.push) }}
205+ uses : docker/login-action@v3
206+ with :
207+ username : ${{ secrets.REGISTRY_USERNAME }}
208+ password : ${{ secrets.REGISTRY_PASSWORD }}
209+ - name : Build
210+ id : build
211+ uses : docker/bake-action@v6
212+ with :
213+ pull : true
214+ load : ${{ !fromJson(needs.prepare.outputs.push) }}
215+ targets : gnu-static
216+ set : |
217+ ${{ (github.event_name == 'pull_request' || matrix.platform == 'linux/arm64') && 'gnu-static.args.NO_COMPRESS=1' || '' }}
218+ *.tags=
219+ *.platform=${{ matrix.platform }}
220+ *.cache-from=type=gha,scope=${{ needs.prepare.outputs.ref || github.ref }}-gnu-static
221+ *.cache-from=type=gha,scope=refs/heads/main-gnu-static
222+ *.cache-to=type=gha,scope=${{ needs.prepare.outputs.ref || github.ref }}-gnu-static,ignore-error=true
223+ ${{ fromJson(needs.prepare.outputs.push) && format('*.output=type=image,name={0}-gnu,push-by-digest=true,name-canonical=true,push=true', env.IMAGE_NAME) || '' }}
224+ env :
225+ SHA : ${{ github.sha }}
226+ VERSION : ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || 'dev' }}
227+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
228+ - # Workaround for https://github.com/actions/runner/pull/2477#issuecomment-1501003600
229+ name : Export metadata
230+ if : fromJson(needs.prepare.outputs.push)
231+ run : |
232+ mkdir -p /tmp/metadata-gnu
233+
234+ # shellcheck disable=SC2086
235+ digest=$(jq -r '."gnu-static"."containerimage.digest"' <<< ${METADATA})
236+ touch "/tmp/metadata-gnu/${digest#sha256:}"
237+ env :
238+ METADATA : ${{ steps.build.outputs.metadata }}
239+ - name : Upload metadata
240+ if : fromJson(needs.prepare.outputs.push)
241+ uses : actions/upload-artifact@v4
242+ with :
243+ name : metadata-gnu-static-${{ steps.prepare.outputs.sanitized_platform }}
244+ path : /tmp/metadata-gnu/*
245+ if-no-files-found : error
246+ retention-days : 1
247+ - name : Copy binary
248+ run : |
249+ # shellcheck disable=SC2034
250+ digest=$(jq -r '."gnu-static"."${{ fromJson(needs.prepare.outputs.push) && 'containerimage.digest' || 'containerimage.config.digest' }}"' <<< "${METADATA}")
251+ docker create --platform=${{ matrix.platform }} --name gnu-static "${{ fromJson(needs.prepare.outputs.push) && format('{0}-gnu@{1}', env.IMAGE_NAME, '${digest}') || '${digest}' }}"
252+ docker cp "gnu-static:/go/src/app/dist/${BINARY}" "${BINARY}-gnu"
253+ env :
254+ METADATA : ${{ steps.build.outputs.metadata }}
255+ BINARY : frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}
256+ - name : Upload artifact
257+ if : ${{ !fromJson(needs.prepare.outputs.push) }}
258+ uses : actions/upload-artifact@v4
259+ with :
260+ name : frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}-gnu
261+ path : frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}-gnu
262+ - name : Upload assets
263+ if : fromJson(needs.prepare.outputs.push) && (needs.prepare.outputs.ref || github.ref_type == 'tag')
264+ run : gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}" frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}-gnu --repo dunglas/frankenphp --clobber
265+ env :
266+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
267+ - if : fromJson(needs.prepare.outputs.push) && (needs.prepare.outputs.ref || github.ref_type == 'tag')
268+ uses : actions/attest-build-provenance@v2
269+ with :
270+ subject-path : ${{ github.workspace }}/frankenphp-linux-*-gnu
271+ - name : Run sanity checks
272+ run : |
273+ "${BINARY}" version
274+ "${BINARY}" list-modules | grep frankenphp
275+ "${BINARY}" list-modules | grep http.encoders.br
276+ "${BINARY}" list-modules | grep http.handlers.mercure
277+ "${BINARY}" list-modules | grep http.handlers.mercure
278+ "${BINARY}" list-modules | grep http.handlers.vulcain
279+ env :
280+ BINARY : ./frankenphp-linux-${{ matrix.platform == 'linux/amd64' && 'x86_64' || 'aarch64' }}-gnu
281+
179282 # Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
180283 push :
181284 runs-on : ubuntu-24.04
182285 needs :
183286 - prepare
184287 - build-linux
288+ - build-linux-gnu
185289 if : fromJson(needs.prepare.outputs.push)
186290 steps :
187291 - name : Download metadata
@@ -190,6 +294,12 @@ jobs:
190294 pattern : metadata-static-builder-*
191295 path : /tmp/metadata
192296 merge-multiple : true
297+ - name : Download GNU metadata
298+ uses : actions/download-artifact@v4
299+ with :
300+ pattern : metadata-gnu-static-*
301+ path : /tmp/metadata-gnu
302+ merge-multiple : true
193303 - name : Set up Docker Buildx
194304 uses : docker/setup-buildx-action@v3
195305 - name : Login to DockerHub
@@ -205,12 +315,26 @@ jobs:
205315 $(printf "${IMAGE_NAME}@sha256:%s " *)
206316 env :
207317 METADATA : ${{ needs.prepare.outputs.metadata }}
318+ - name : Create GNU manifest list and push
319+ working-directory : /tmp/metadata-gnu
320+ run : |
321+ # shellcheck disable=SC2046,SC2086
322+ docker buildx imagetools create $(jq -cr '.target."gnu-static".tags | map("-t " + . + "-gnu") | join(" ")' <<< "${GNU_METADATA}") \
323+ $(printf "${IMAGE_NAME}-gnu@sha256:%s " *)
324+ env :
325+ GNU_METADATA : ${{ needs.prepare.outputs.gnu_metadata }}
208326 - name : Inspect image
209327 run : |
210328 # shellcheck disable=SC2046,SC2086
211329 docker buildx imagetools inspect "$(jq -cr '.target."static-builder".tags | first' <<< "${METADATA}")"
212330 env :
213331 METADATA : ${{ needs.prepare.outputs.metadata }}
332+ - name : Inspect GNU image
333+ run : |
334+ # shellcheck disable=SC2046,SC2086
335+ docker buildx imagetools inspect "$(jq -cr '.target."gnu-static".tags | first' <<< "${GNU_METADATA}")-gnu"
336+ env :
337+ GNU_METADATA : ${{ needs.prepare.outputs.gnu_metadata }}
214338
215339 build-mac :
216340 strategy :
0 commit comments