239 lines
6.4 KiB
YAML
239 lines
6.4 KiB
YAML
# SPDX-FileCopyrightText: 2025 William Bell
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*' # Any tag
|
|
|
|
jobs:
|
|
build-linux-x86_64:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install build tools
|
|
run: sudo apt-get update && sudo apt-get install -y flex bison
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.x'
|
|
|
|
- name: Install Conan
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install conan
|
|
conan profile detect
|
|
|
|
- name: Build
|
|
run: |
|
|
conan install . --build=missing
|
|
conan build .
|
|
|
|
- name: Package
|
|
run: |
|
|
TAG=${GITHUB_REF##refs/tags/}
|
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
ARCH=$(uname -m)
|
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
|
TAR="$FOLDER.tar.gz"
|
|
mv build/bin "$FOLDER"
|
|
cp LICENSE.txt "$FOLDER"
|
|
tar -czf "$TAR" "$FOLDER"
|
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: linux-${{ matrix.arch }}-artifact
|
|
path: ${{ env.TAR_NAME }}
|
|
|
|
build-linux-arm64:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Run build in arm64 container
|
|
run: |
|
|
docker run --rm --platform linux/arm64 \
|
|
-v $PWD:/work -w /work \
|
|
ubuntu:latest \
|
|
bash -c "
|
|
apt-get update && apt-get install -y python3-pip g++ flex bison &&
|
|
pip install --break-system-packages conan &&
|
|
conan profile detect --force &&
|
|
conan install . --build=missing &&
|
|
conan build .
|
|
"
|
|
|
|
- name: Package
|
|
run: |
|
|
TAG=${GITHUB_REF##refs/tags/}
|
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
ARCH=arm64
|
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
|
TAR="$FOLDER.tar.gz"
|
|
mv build/bin "$FOLDER"
|
|
cp LICENSE.txt "$FOLDER"
|
|
tar -czf "$TAR" "$FOLDER"
|
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: linux-${{ matrix.arch }}-artifact
|
|
path: ${{ env.TAR_NAME }}
|
|
|
|
build-macos:
|
|
runs-on: macos-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x86_64, arm64] # build both architectures
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install build tools
|
|
run: brew install flex bison
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.x'
|
|
|
|
- name: Install Conan
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install conan
|
|
if [ "${{ matrix.arch }}" = "x86_64" ] && [ "$(uname -m)" = "arm64" ]; then
|
|
arch -x86_64 conan profile detect
|
|
else
|
|
conan profile detect
|
|
fi
|
|
|
|
- name: Build
|
|
run: |
|
|
BUILD_DIR="build_${{ matrix.arch }}"
|
|
mkdir -p "$BUILD_DIR"
|
|
cd "$BUILD_DIR"
|
|
|
|
# Use Rosetta for x86_64 builds on Apple Silicon
|
|
if [ "${{ matrix.arch }}" = "x86_64" ] && [ "$(uname -m)" = "arm64" ]; then
|
|
arch -x86_64 bash -c "
|
|
export CMAKE_OSX_ARCHITECTURES=x86_64
|
|
conan install .. --build=missing
|
|
conan build ..
|
|
"
|
|
else
|
|
export CMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}"
|
|
conan install .. --build=missing
|
|
conan build ..
|
|
fi
|
|
|
|
cd ..
|
|
|
|
- name: Package
|
|
run: |
|
|
TAG=${GITHUB_REF##refs/tags/}
|
|
OS="macos"
|
|
ARCH="${{ matrix.arch }}"
|
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
|
TAR="$FOLDER.tar.gz"
|
|
mv build/bin "$FOLDER"
|
|
cp LICENSE.txt "$FOLDER"
|
|
tar -czf "$TAR" "$FOLDER"
|
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: macos-${{ matrix.arch }}-artifact
|
|
path: ${{ env.TAR_NAME }}
|
|
|
|
build-windows:
|
|
runs-on: windows-latest
|
|
defaults:
|
|
run:
|
|
shell: msys2 {0}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: MINGW64
|
|
update: true
|
|
install: >
|
|
base-devel
|
|
mingw-w64-x86_64-gcc
|
|
mingw-w64-x86_64-make
|
|
mingw-w64-x86_64-cmake
|
|
mingw-w64-x86_64-python
|
|
mingw-w64-x86_64-python-pip
|
|
msys/flex
|
|
|
|
- name: Install Conan
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install conan
|
|
conan profile detect
|
|
|
|
- name: Build Project
|
|
run: |
|
|
conan install . --profile mingw-profile.txt --build=missing
|
|
conan build . --profile mingw-profile.txt
|
|
|
|
- name: Package
|
|
run: |
|
|
TAG=${GITHUB_REF##refs/tags/}
|
|
OS="windows"
|
|
ARCH=$(uname -m)
|
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
|
TAR="$FOLDER.tar.gz"
|
|
mv build/bin "$FOLDER"
|
|
cp LICENSE.txt "$FOLDER"
|
|
tar -czf "$TAR" "$FOLDER"
|
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: windows-artifact
|
|
path: ${{ env.TAR_NAME }}
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-linux-x86_64, build-linux-arm64, build-macos, build-windows]
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ./artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Create GitHub Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
tag: ${{ github.ref_name }}
|
|
name: Release ${{ github.ref_name }}
|
|
body: Automated release based on tag ${{ github.ref_name }}
|
|
draft: false
|
|
prerelease: ${{ startsWith(github.ref_name, 'prerelease-') }}
|
|
artifacts: "./artifacts/*" |