123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- ---
- name: Build binary releases
- on:
- pull_request:
- branches:
- - main
- push:
- branches:
- - main
- tags:
- - v*.*.*
- workflow_dispatch:
- inputs:
- version:
- description: 'FrankenPHP version'
- required: false
- type: string
- schedule:
- - cron: '0 0 * * *'
- jobs:
- prepare:
- runs-on: ubuntu-latest
- outputs:
- ref: ${{ steps.ref.outputs.ref || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }}
- steps:
- -
- name: Get latest release
- id: ref
- if: github.event_name == 'schedule'
- run: echo ref="$(gh release view --repo dunglas/frankenphp --json tagName --jq '.tagName')" >> "${GITHUB_OUTPUT}"
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- build-linux:
- name: Build Linux x86_64 binary
- runs-on: ubuntu-latest
- needs: [ prepare ]
- steps:
- -
- uses: actions/checkout@v4
- with:
- ref: ${{ needs.prepare.outputs.ref }}
- -
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
- with:
- version: latest
- -
- name: Login to DockerHub
- if: needs.prepare.outputs.ref || 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: ${{ (!needs.prepare.outputs.ref && !startsWith(github.ref, 'refs/tags/') && (github.ref != 'refs/heads/main' || github.event_name == 'pull_request')) && true || false }}
- push: ${{ (needs.prepare.outputs.ref || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) && true || false }}
- targets: static-builder
- set: |
- *.cache-from=type=gha,scope=${{needs.prepare.outputs.ref || github.ref}}-static-builder
- *.cache-from=type=gha,scope=refs/heads/main-static-builder
- *.cache-to=type=gha,scope=${{needs.prepare.outputs.ref || github.ref}}-static-builder,ignore-error=true
- env:
- SHA: ${{github.sha}}
- VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || github.sha}}
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- -
- name: Pull Docker image
- if: needs.prepare.outputs.ref || 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: needs.prepare.outputs.ref || github.ref_type == 'tag'
- run: gh release upload "${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}" frankenphp-linux-x86_64 --repo dunglas/frankenphp --clobber
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- -
- name: Upload artifact
- if: github.ref_type == 'branch'
- uses: actions/upload-artifact@v3
- with:
- name: frankenphp-linux-x86_64
- path: frankenphp-linux-x86_64
- build-mac:
- name: Build macOS x86_64 binaries
- runs-on: macos-latest
- needs: [ prepare ]
- env:
- HOMEBREW_NO_AUTO_UPDATE: 1
- steps:
- -
- uses: actions/checkout@v4
- with:
- ref: ${{ needs.prepare.outputs.ref }}
- -
- 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}
- elif [ "${GITHUB_EVENT_NAME}" == "schedule" ]; then
- export FRANKENPHP_VERSION="${{ needs.prepare.outputs.ref }}"
- 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 }}
- RELEASE: ${{ (needs.prepare.outputs.ref || github.ref_type == 'tag') && '1' || '' }}
- -
- name: Upload artifact
- if: github.ref_type == 'branch'
- uses: actions/upload-artifact@v3
- with:
- name: frankenphp-mac-x86_64
- path: dist/frankenphp-mac-x86_64
|