# Publishes the custom FrankenPHP image (easy-excel extension baked in) to
# GHCR on every main push (`latest` + sha) and on version tags (semver).
# Tag pushes also attach the standalone frankenphp binary to the release.
name: publish
on:
push:
branches: [main]
tags: ["v*"]
permissions:
contents: write
packages: write
env:
IMAGE: ghcr.io/${{ github.repository_owner }}/frankenphp8.5-easy-excel
jobs:
publish-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# easy_excel_version() (Native::version() on the PHP side) is stamped
# with this at link time, so it matches the vX.Y.Z tag the
# easy-excel-polyfill package is released under (publish-php.yml).
# Non-tag builds (main pushes) keep the source-level dev default.
- id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "value=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "value=0.0.0-dev" >> "$GITHUB_OUTPUT"
fi
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
target: runner
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ steps.version.outputs.value }}
cache-from: type=gha,scope=publish
cache-to: type=gha,scope=publish,mode=max
attach-binary:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: publish-image
steps:
- uses: actions/checkout@v5
- uses: docker/setup-buildx-action@v3
- name: Build binary (linux/amd64)
run: |
docker build --target=build \
--build-arg VERSION="${GITHUB_REF#refs/tags/v}" \
-t easy-excel-build .
id=$(docker create easy-excel-build)
docker cp "$id":/usr/local/bin/frankenphp-easy-excel ./frankenphp-easy-excel-linux-amd64
docker rm "$id"
- name: Attach to release
uses: softprops/action-gh-release@v2
with:
files: frankenphp-easy-excel-linux-amd64
generate_release_notes: true
|