feat: add FrankenPHP version to the version command

This commit is contained in:
Kévin Dunglas 2023-07-17 16:19:40 +02:00
parent 6c215b8b10
commit 7620c8658a
4 changed files with 17 additions and 11 deletions

View File

@ -28,12 +28,12 @@ jobs:
version: latest
- name: Create variants matrix
id: matrix
id: matrix
run: |
METADATA=$(docker buildx bake --print)
METADATA=$(docker buildx bake --print | jq -c)
echo "metadata=$METADATA" >> "$GITHUB_OUTPUT"
echo "variants=$(jq -c '.group.default.targets|map(sub("runner-|builder-"; ""))|unique' <<< $METADATA)" >> "$GITHUB_OUTPUT"
echo "platforms=$(jq -c 'first(.target[]) | .platforms' <<< $METADATA)" >> "$GITHUB_OUTPUT"
echo "metadata=$(jq -c <<< $METADATA)" >> "$GITHUB_OUTPUT"
env:
LATEST: '1' # TODO: unset this variable when releasing the first tagged version
SHA: ${{github.sha}}
@ -83,6 +83,7 @@ jobs:
uses: docker/bake-action@v3
with:
pull: true
load: ${{!fromJson(needs.prepare.outputs.push)}}
targets: |
builder-${{matrix.variant}}
runner-${{matrix.variant}}
@ -93,7 +94,7 @@ jobs:
*.cache-from=type=gha,scope=${{github.ref}}-${{matrix.platform}}
*.cache-from=type=gha,scope=refs/heads/main-${{matrix.platform}}
*.cache-to=type=gha,scope=${{github.ref}}-${{matrix.platform}}
*.output=type=image,name=dunglas/frankenphp,push-by-digest=true,name-canonical=true,push=${{ needs.prepare.outputs.push }}
${{fromJson(needs.prepare.outputs.push) && '*.output=type=image,name=dunglas/frankenphp,push-by-digest=true,name-canonical=true,push=true' || ''}}
env:
LATEST: '1' # TODO: unset this variable when releasing the first tagged version
SHA: ${{github.sha}}
@ -133,11 +134,11 @@ jobs:
- name: Run tests
if: '!matrix.qemu'
continue-on-error: true
continue-on-error: ${{fromJson(needs.prepare.outputs.push)}}
run: |
docker run --platform=${{matrix.platform}} --rm \
dunglas/frankenphp@$(jq -r '."builder-${{matrix.variant}}"."containerimage.digest"' <<< $METADATA) \
"sh -c 'go test ${{matrix.race}} -v ./... && cd caddy && go test ${{matrix.race}} -v ./...'"
$(jq -r '."builder-${{matrix.variant}}"."containerimage.config.digest"' <<< $METADATA) \
"sh -c 'frankenphp version && go test ${{matrix.race}} -v ./... && cd caddy && go test ${{matrix.race}} -v ./...'"
env:
METADATA: ${{steps.build.outputs.metadata}}
@ -160,8 +161,6 @@ jobs:
name: metadata-${{matrix.target}}-${{matrix.variant}}
path: /tmp/metadata
- run: ls -R /tmp/metadata
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:

View File

@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1
FROM php-base AS builder
ARG FRANKENPHP_VERSION='dev'
COPY --from=golang-base /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang-base /usr/local/go /usr/local/go
@ -40,7 +42,7 @@ COPY testdata testdata
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS
RUN cd caddy/frankenphp && \
go build && \
go build -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION Caddy'" && \
cp frankenphp /usr/local/bin && \
cp /go/src/app/caddy/frankenphp/Caddyfile /etc/Caddyfile

View File

@ -1,6 +1,8 @@
# syntax=docker/dockerfile:1
FROM php-base AS builder
ARG FRANKENPHP_VERSION='dev'
COPY --from=golang-base /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang-base /usr/local/go /usr/local/go
@ -39,7 +41,7 @@ COPY testdata testdata
ENV CGO_LDFLAGS="-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz $PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS
RUN cd caddy/frankenphp && \
go build && \
go build -ldflags "-X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP $FRANKENPHP_VERSION Caddy'" && \
cp frankenphp /usr/local/bin && \
cp /go/src/app/caddy/frankenphp/Caddyfile /etc/Caddyfile

View File

@ -87,4 +87,7 @@ target "default" {
"org.opencontainers.image.version" = VERSION
"org.opencontainers.image.revision" = SHA
}
args = {
FRANKENPHP_VERSION = VERSION
}
}