ci: add Docker tags containing the minor and major PHP version #95
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build binary releases | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
tags: | |
- v*.*.* | |
workflow_dispatch: | |
inputs: {} | |
jobs: | |
release: | |
if: github.ref_type == 'tag' | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
with: | |
generateReleaseNotes: true | |
allowUpdates: true | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
build-linux: | |
name: Build Linux x86_64 binary | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
version: latest | |
- | |
name: Login to DockerHub | |
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.REGISTRY_USERNAME}} | |
password: ${{secrets.REGISTRY_PASSWORD}} | |
- | |
name: Build | |
id: build | |
uses: docker/bake-action@v4 | |
with: | |
pull: true | |
load: ${{toJson(!startsWith(github.ref, 'refs/tags/') && (github.ref != 'refs/heads/main' || github.event_name == 'pull_request'))}} | |
push: ${{toJson(startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request'))}} | |
targets: static-builder | |
set: | | |
*.cache-from=type=gha,scope=${{github.ref}}-static-builder | |
*.cache-from=type=gha,scope=refs/heads/main-static-builder | |
*.cache-to=type=gha,scope=${{github.ref}}-static-builder | |
env: | |
LATEST: '1' # TODO: unset this variable when releasing the first stable version | |
SHA: ${{github.sha}} | |
VERSION: ${{github.ref_type == 'tag' && github.ref_name || github.sha}} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Pull Docker image | |
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') | |
run: docker pull dunglas/frankenphp:static-builder | |
- | |
name: Copy binary | |
run: docker cp "$(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/dist/frankenphp-linux-x86_64" frankenphp-linux-x86_64 ; docker rm static-builder | |
- | |
name: Upload asset | |
if: github.ref_type == 'tag' | |
uses: ncipollo/release-action@v1 | |
with: | |
generateReleaseNotes: true | |
allowUpdates: true | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
artifacts: frankenphp-linux-x86_64 | |
- | |
name: Upload artifact | |
if: github.ref_type == 'branch' | |
uses: actions/upload-artifact@v3 | |
with: | |
path: frankenphp-linux-x86_64 | |
build-mac: | |
name: Build macOS x86_64 binaries | |
runs-on: macos-latest | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
cache-dependency-path: | | |
go.sum | |
caddy/go.sum | |
- | |
name: Set FRANKENPHP_VERSION | |
run: | | |
if [ "$GITHUB_REF_TYPE" == "tag" ]; then export FRANKENPHP_VERSION=${GITHUB_REF_NAME:1}; else export FRANKENPHP_VERSION=$GITHUB_SHA; fi | |
echo "FRANKENPHP_VERSION=$FRANKENPHP_VERSION" >> "$GITHUB_ENV" | |
- | |
name: Build FrankenPHP | |
run: ./build-static.sh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Upload asset | |
if: github.ref_type == 'tag' | |
uses: ncipollo/release-action@v1 | |
with: | |
generateReleaseNotes: true | |
allowUpdates: true | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
artifacts: dist/frankenphp-mac-x86_64 | |
- | |
name: Upload binary | |
uses: actions/upload-artifact@v3 | |
with: | |
path: dist/frankenphp-mac-x86_64 |