Merge branch 'main' of https://github.com/DataZooDE/flapi #96
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 flAPI | |
permissions: | |
contents: write | |
packages: write | |
issues: write | |
pull-requests: write | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# ------------------------------------------------------------------------------------------------- | |
# Windows Build (AMD64) | |
# ------------------------------------------------------------------------------------------------- | |
windows-build: | |
runs-on: windows-latest | |
env: | |
VCPKG_DEFAULT_TRIPLET: x64-windows-static | |
VCPKG_ROOT: ${{ github.workspace }}/vcpkg | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Setup MSVC | |
uses: microsoft/setup-msbuild@v2 | |
- name: Setup Ccache | |
uses: hendrikmuhs/ccache-action@main | |
with: | |
key: ${{ github.job }}-windows | |
- name: Build | |
shell: cmd | |
run: | | |
mkdir -p build/release | |
cd build/release | |
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF ../.. | |
cmake --build . --config Release | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: flapi-windows-amd64 | |
path: build/release/flapi.exe | |
if-no-files-found: error | |
# ------------------------------------------------------------------------------------------------- | |
# Linux Matrix Build (AMD64 + ARM64) | |
# ------------------------------------------------------------------------------------------------- | |
linux-build: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
arch: [amd64, arm64] | |
env: | |
BUILD_ARCH: ${{ matrix.arch }} | |
BUILD_IMAGE: flapi_build_${{ matrix.arch }} | |
FLAPI_CROSS_COMPILE: ${{ matrix.arch == 'arm64' && 'arm64' || '' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Setup Ccache | |
uses: hendrikmuhs/ccache-action@main | |
with: | |
key: ${{ github.job }}-${{ matrix.arch }} | |
- name: Build Docker image | |
shell: bash | |
run: | | |
docker build \ | |
-t ${BUILD_IMAGE} \ | |
-f .github/docker/linux_${BUILD_ARCH}/Dockerfile . | |
- name: Run build in docker | |
shell: bash | |
run: | | |
docker run \ | |
${{ matrix.arch == 'arm64' && format('-e FLAPI_CROSS_COMPILE="{0}"', matrix.arch) || '' }} \ | |
-v `pwd`:/build_dir \ | |
-v ~/.ccache:/ccache_dir \ | |
${BUILD_IMAGE} \ | |
bash -c 'cd /build_dir && make clean && make release' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: flapi-linux-${{ matrix.arch }} | |
path: build/release/flapi | |
if-no-files-found: error | |
# ------------------------------------------------------------------------------------------------- | |
# Docker Build and Push Multi-Arch | |
# ------------------------------------------------------------------------------------------------- | |
docker-build: | |
needs: [linux-build] | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare | |
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ env.REPO_OWNER }}/flapi | |
tags: | | |
type=raw,value=latest | |
type=sha,format=long | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Prepare artifacts | |
run: | | |
mkdir -p binaries/amd64 binaries/arm64 | |
cp artifacts/flapi-linux-amd64/flapi binaries/amd64/ | |
cp artifacts/flapi-linux-arm64/flapi binaries/arm64/ | |
chmod +x binaries/amd64/flapi binaries/arm64/flapi | |
- name: Build and push multi-arch image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-contexts: | | |
build=binaries | |
# ------------------------------------------------------------------------------------------------- | |
# macOS Universal | |
# ------------------------------------------------------------------------------------------------- | |
osx-universal: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup Ccache | |
uses: hendrikmuhs/ccache-action@main | |
with: | |
key: ${{ github.job }} | |
- name: Install dependencies | |
shell: bash | |
run: brew install ninja autoconf make libtool pkg-config automake autoconf-archive | |
- name: Build | |
run: make release | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: flapi-macos-universal | |
path: build/universal/flapi | |
if-no-files-found: error | |
retention-days: 90 |