-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3fbaa8
commit 4ecc244
Showing
21 changed files
with
548 additions
and
250 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: build-cli | ||
on: | ||
push: | ||
branches: | ||
- v2 | ||
pull_request: | ||
branches: | ||
- v2 | ||
jobs: | ||
build-linux: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: [ 'amd64', 'arm64' ] | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Configure QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Configure docker | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
platforms: ${{ matrix.platform }} | ||
- name: Expose GitHub Runtime | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
- name: Build sources | ||
run: | | ||
docker buildx build --cache-to type=gha,mode=max,scope=${{ matrix.platform }} --cache-from type=gha,scope=${{ matrix.platform }} --pull --load --platform linux/${{ matrix.platform }} --target cli-base-alpine -t builder . | ||
- name: Copy build | ||
run: | | ||
docker create --name builder builder | ||
docker cp builder:/go/src/app/cli/dist/dphp bin/dphp | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dphp-${{ runner.os }}-${{ matrix.platform }} | ||
path: bin/dphp | ||
build-docker: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Configure QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Configure docker | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Docker | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | ||
- name: Calculate version | ||
run: | | ||
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then | ||
export VERSION=${GITHUB_REF_NAME:1} | ||
else | ||
export VERSION=${GITHUB_SHA} | ||
fi | ||
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}" | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository_owner }}/durable-php/runtime | ||
tags: | | ||
type=schedule,pattern=latest | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
- name: Build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ./ | ||
file: Dockerfile | ||
target: durable-php | ||
build-args: | | ||
VERSION=${{ env.VERSION }} | ||
push: true | ||
pull: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
builder: ${{ steps.buildx.outputs.name }} | ||
cache-from: type=gha,scope=image | ||
cache-to: type=gha,mode=max,scope=image | ||
platforms: linux/amd64,linux/arm64 | ||
build-osx: | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
platform: [ 'arm64', 'x86_64' ] | ||
runs-on: ${{ matrix.platform == 'arm64' && 'macos-14' || 'macos-13' }} | ||
env: | ||
HOMEBREW_NO_AUTO_UPDATE: 1 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '>=1.22' | ||
- name: Configure Version | ||
run: | | ||
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then | ||
export VERSION=${GITHUB_REF_NAME:1} | ||
else | ||
export VERSION=${GITHUB_SHA} | ||
fi | ||
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}" | ||
- name: Configure cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: dist | ||
key: ${{ matrix.platform }}-${{ hashFiles('cli/*.mod') }} | ||
- name: Run doctor | ||
run: BUILD=no cli/build-php.sh | ||
- name: Build php | ||
run: cli/build-php.sh | ||
- name: Build cli | ||
run: cd cli && ./build.sh | ||
- run: ls -lah cli/dist/ | ||
- run: ls -lah dist/ || true | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dphp-${{ runner.os }}-${{ matrix.platform }} | ||
path: cli/dist/dphp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
TARGET := dphp-linux-x86_64 | ||
TARGET := dphp-linux-* | ||
BIN_PATH := ../bin | ||
DOCKER_IMAGE := builder | ||
DOCKER_TARGET := cli-base-alpine | ||
BUILD_PATH := /go/src/app/cli/dist | ||
|
||
${BIN_PATH}/${TARGET}: cli.go */* go.mod build.sh build-php.sh ../Dockerfile | ||
mkdir -p ${BIN_PATH} | ||
cd .. && docker build --pull --target ${DOCKER_TARGET} -t ${DOCKER_IMAGE} . | ||
docker create --name builder builder || ( docker rm -f builder && false ) | ||
docker cp ${DOCKER_IMAGE}:${BUILD_PATH}/${TARGET} ${BIN_PATH}/${TARGET} || ( docker rm -f builder && false ) | ||
docker rm -f builder | ||
cd .. && docker buildx build --cache-to type=gha --cache-from type=gha --pull --load --platform ${PLATFORM} --target ${DOCKER_TARGET} -t ${DOCKER_IMAGE} . | ||
docker create --name ${DOCKER_IMAGE} ${DOCKER_IMAGE} || ( docker rm -f ${DOCKER_IMAGE} && false ) | ||
docker cp ${DOCKER_IMAGE}:${BUILD_PATH}/${TARGET} ${BIN_PATH}/ || ( docker rm -f ${DOCKER_IMAGE} && false ) | ||
docker rm -f ${DOCKER_IMAGE} | ||
upx -9 --force-pie ../bin/dphp-* | ||
|
||
../dist: ${BIN_PATH}/${TARGET} | ||
docker create --name builder builder | ||
docker cp ${DOCKER_IMAGE}:${BUILD_PATH} ../dist |
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
Oops, something went wrong.